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