[rules-users] unmarshal global variable
Michael Anstis
michael.anstis at gmail.com
Mon Jan 7 11:52:45 EST 2013
Does that rule work before unmarshalling?
I assume "productPricer" is the global but it is undefined in the DRL
fragment you paste.
You'd need to include a "variables" entry in the RuleSet section. See
section "2.4.4.2. Rule Set Entries" in
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html/ch02.html#d0e1157
.
If what you provided was incomplete and you already do this, the problem
could be elsewhere.
On 7 January 2013 16:41, Ormond, Alex C. (GDLP) <
ACOrmond at greatdanetrailers.com> wrote:
> Thanks for the response. The first rule table in the spreadsheet
> (kinda) looks like this:
>
> RuleTable Constants
> NAME CONDITION ACTION ACTION
>
> eval(! productPricer.isConstantsSet($1) )
> productPricer.setConstant($1, $2);
> productPricer.setConstantsSet($1);
> Rule Name Set?
> ProductName TRUE "NAME", "Champion CL"
> DefaultCost TRUE "COST", "80000"
> DefaultPrice TRUE "PRICE", "100000"
> DefaultLength TRUE "LENGTH", "53"
> Done TRUE TRUE
>
>
> The first rule generated looks like this:
>
> rule "ProductName"
> when
> eval(! productPricer.isConstantsSet() )
> then
> productPricer.setConstant("NAME", "Champion CL");
> end
>
>
> Alex
>
>
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
> Sent: Monday, January 07, 2013 11:22 AM
> To: Rules Users List
> Subject: Re: [rules-users] unmarshal global variable
>
> The crucial info is: what is in the first table, how do you insert this
> data?
> Is it a DRL global? A fact? How does the (generated) rule look like?
> -W
>
> On 07/01/2013, acormond <acormond at greatdanetrailers.com> wrote:
> > Gentlepeople,
> >
> > I am fairly new to Drools and have what I hope is a simple question.
> I am
> > attempting to marshal (serialize) a Drools knowledge session and then
> > unmarshall it. The marshalling works but the unmarshalling fails with
> a
> > null pointer exception. The error is apparently with unmarshalling a
> > global
> > variable in the session.
> >
> > The session is created from a spreadsheet (decision table). This
> > spreadsheet
> > has two RuleTables. The first of these exists solely so that I can
> enter
> > some
> > constants into the session, specifically the name and price of the
> product
> > the
> > spreadsheet is dealing with. The second ruletable is where the rules
> are
> > specified. The exception occurs when unmarshalling the first rule in
> the
> > first
> > rule table. If, as a test, I eliminate the first rule table, then I
> can
> > successfully marshal and unmarshall the session.
> >
> > The marshalling is done using the following, simplified, code:
> >
> > Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
> > File droolsSessionFile = new File(MARSHAL_FILE);
> > foStream = new FileOutputStream(droolsSessionFile);
> > baos = new ByteArrayOutputStream();
> > marshaller.marshall(baos, ksession);
> > baos.writeTo(foStream);
> >
> > and the unmarshalling is done like this:
> >
> > Marshaller marshaller =
> > MarshallerFactory.newMarshaller(pricingProcessor.getKnowledgeBase());
> > FileInputStream fis = new FileInputStream(MARSHAL_FILE);
> > StatefulKnowledgeSession ksession = marshaller.unmarshall(fis);
> >
> >
> > So, where did I go wrong? Perhaps I need to deal with the global
> variable
> > differently, perhaps by putting it in the knowledgeBase before I
> unmarshall
> > the session?
> >
> > Thank you for any help.
> >
> > Alex Ormond
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://drools.46999.n3.nabble.com/unmarshal-global-variable-tp4021375.ht
> ml
> > Sent from the Drools: User forum mailing list archive at Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130107/08ea3cf3/attachment.html
More information about the rules-users
mailing list