[rules-users] unmarshal global variable

acormond acormond at greatdanetrailers.com
Mon Jan 7 10:31:08 EST 2013


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.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list