[rules-users] AfterEvaluatorDefinition NullPointer Exception in deserialized ksession

2013-10-11 Thread Alexander Wolf
[Drools 5.5.0 Final]

I wrote a webserver that keeps StatefulKnowledgeSessions running in Stream 
mode. When the server is stopped, the sessions are serialized and stored in a 
database. When the server is restarted, the existing sessions are restored / 
deserialized.

Some time after recreating the session and inserting some events I get the 
following exception:

java.lang.NullPointerException: null
at 
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:351)
...

Apparently the exception seems to be related to a rule that uses temporal 
reasoning.
After getting it once, the session seems to be corrupt - from now on every 
time I call ksession.insert(event) the same exception occurs.
When I serialize the session and attempt to deserialize it, I get a long stack 
trace -- I can not deserialize it anymore. (as apparently it is corrupted).
When I run the server with the same events/sessions without stopping 
(serialization/deserialization) the exception does not occur)

Can I do anything to prevent this behaviour? I thought maybe the after 
timer/trigger is somehow still active when I serialize the ksession.
I tried ksession.halt() before serialization, but with no effect. 

Any ideas?


signature.asc
Description: Message signed with OpenPGP using GPGMail
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] AfterEvaluatorDefinition NullPointer Exception in deserialized ksession

2013-10-11 Thread Demian Calcaprina
Hey Alexander,

Would this be related to this?

https://issues.jboss.org/browse/DROOLS-243

If it is this one, you can do something like this as a workaround before
constructing the KBase:

Operator op = BeforeEvaluatorDefinition.BEFORE;
Operator op = AfterEvaluatorDefinition.AFTER;

This will cause the evaluation definition to be put in  memory.

Hope this helps!

Demian


On Fri, Oct 11, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.netwrote:

 [Drools 5.5.0 Final]

 I wrote a webserver that keeps StatefulKnowledgeSessions running in Stream
 mode. When the server is stopped, the sessions are serialized and stored in
 a database. When the server is restarted, the existing sessions are
 restored / deserialized.

 Some time after recreating the session and inserting some events I get the
 following exception:

 java.lang.NullPointerException: null
 at
 org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:351)
 ...

 Apparently the exception seems to be related to a rule that uses temporal
 reasoning.
 After getting it once, the session seems to be corrupt - from now on
 every time I call ksession.insert(event) the same exception occurs.
 When I serialize the session and attempt to deserialize it, I get a long
 stack trace -- I can not deserialize it anymore. (as apparently it is
 corrupted).
 When I run the server with the same events/sessions without stopping
 (serialization/deserialization) the exception does not occur)

 Can I do anything to prevent this behaviour? I thought maybe the after
 timer/trigger is somehow still active when I serialize the ksession.
 I tried ksession.halt() before serialization, but with no effect.

 Any ideas?

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] AfterEvaluatorDefinition NullPointer Exception in deserialized ksession

2013-10-11 Thread Alexander Wolf
Hey Demian, 

thank you! This might actually be related. But how do I get the reference to 
these Operators to (re)set them?

This is my unmarshalling code (pretty simple and basic..):

ByteArrayInputStream bais = new ByteArrayInputStream(serializedKnowledgeBase);
ObjectInputStream ois = new ObjectInputStream(bais);
kbase = (KnowledgeBase)ois.readObject();

Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
ByteArrayInputStream bais2 = new 
ByteArrayInputStream(serializedKnowledgeSession);
knowledgeSession = marshaller.unmarshall(bais2);

Also: Is this going to be fixed in 5.6.0 ? (@Mark Proctor?)

- Alex


On 11.10.2013, at 16:09, Demian Calcaprina calcacue...@gmail.com wrote:

 Hey Alexander, 
 
 Would this be related to this?
 
 https://issues.jboss.org/browse/DROOLS-243
 
 If it is this one, you can do something like this as a workaround before 
 constructing the KBase:
 
 Operator op = BeforeEvaluatorDefinition.BEFORE;
 Operator op = AfterEvaluatorDefinition.AFTER;
 
 This will cause the evaluation definition to be put in  memory.
 
 Hope this helps!
 
 Demian
 
 
 On Fri, Oct 11, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.net 
 wrote:
 [Drools 5.5.0 Final]
 
 I wrote a webserver that keeps StatefulKnowledgeSessions running in Stream 
 mode. When the server is stopped, the sessions are serialized and stored in a 
 database. When the server is restarted, the existing sessions are restored / 
 deserialized.
 
 Some time after recreating the session and inserting some events I get the 
 following exception:
 
 java.lang.NullPointerException: null
 at 
 org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:351)
 ...
 
 Apparently the exception seems to be related to a rule that uses temporal 
 reasoning.
 After getting it once, the session seems to be corrupt - from now on every 
 time I call ksession.insert(event) the same exception occurs.
 When I serialize the session and attempt to deserialize it, I get a long 
 stack trace -- I can not deserialize it anymore. (as apparently it is 
 corrupted).
 When I run the server with the same events/sessions without stopping 
 (serialization/deserialization) the exception does not occur)
 
 Can I do anything to prevent this behaviour? I thought maybe the after 
 timer/trigger is somehow still active when I serialize the ksession.
 I tried ksession.halt() before serialization, but with no effect.
 
 Any ideas?
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] AfterEvaluatorDefinition NullPointer Exception in deserialized ksession

2013-10-11 Thread Demian Calcaprina
Yes.. but you can include these two lines before this, to check.

Operator op = BeforeEvaluatorDefinition.BEFORE;
Operator op = AfterEvaluatorDefinition.AFTER;

The problem in that, for example, for the before,

https://github.com/droolsjbpm/drools/blob/5.5.x/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java#L82

If you don-t mention not use this class before trying to unmarshall it, the
operator is not added to the operators registry, and thus NPE is thrown.

 public static final Operator BEFORE=
Operator.addOperatorToRegistry( before,

  false );

In the ticket I included a patch to fix it, I have one thing pending to add
to the pull request in order to be ready to be merged. But the workaround
of just mentioning the evaluator definitions so they are added to the
operators list, before doing the unmarshall, has worked for me.

Thanks,

Demian

Demian


On Fri, Oct 11, 2013 at 12:09 PM, Alexander Wolf m...@alexander-wolf.netwrote:

 Hey Demian,

 thank you! This might actually be related. But how do I get the reference
 to these Operators to (re)set them?

 This is my unmarshalling code (pretty simple and basic..):

 ByteArrayInputStream bais = new ByteArrayInputStream(
 serializedKnowledgeBase);
 ObjectInputStream ois = new ObjectInputStream(bais);
 kbase = (KnowledgeBase)ois.readObject();

 Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
 ByteArrayInputStream bais2 = new ByteArrayInputStream(
 serializedKnowledgeSession);
 knowledgeSession = marshaller.unmarshall(bais2);

 Also: Is this going to be fixed in 5.6.0 ? (@Mark Proctor?)

 - Alex


 On 11.10.2013, at 16:09, Demian Calcaprina calcacue...@gmail.com wrote:

 Hey Alexander,

 Would this be related to this?

 https://issues.jboss.org/browse/DROOLS-243

 If it is this one, you can do something like this as a workaround before
 constructing the KBase:

 Operator op = BeforeEvaluatorDefinition.BEFORE;
 Operator op = AfterEvaluatorDefinition.AFTER;

 This will cause the evaluation definition to be put in  memory.

 Hope this helps!

 Demian


 On Fri, Oct 11, 2013 at 9:21 AM, Alexander Wolf 
 m...@alexander-wolf.netwrote:

 [Drools 5.5.0 Final]

 I wrote a webserver that keeps StatefulKnowledgeSessions running in
 Stream mode. When the server is stopped, the sessions are serialized and
 stored in a database. When the server is restarted, the existing sessions
 are restored / deserialized.

 Some time after recreating the session and inserting some events I get
 the following exception:

 java.lang.NullPointerException: null
 at
 org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:351)
 ...

 Apparently the exception seems to be related to a rule that uses temporal
 reasoning.
 After getting it once, the session seems to be corrupt - from now on
 every time I call ksession.insert(event) the same exception occurs.
 When I serialize the session and attempt to deserialize it, I get a long
 stack trace -- I can not deserialize it anymore. (as apparently it is
 corrupted).
 When I run the server with the same events/sessions without stopping
 (serialization/deserialization) the exception does not occur)

 Can I do anything to prevent this behaviour? I thought maybe the after
 timer/trigger is somehow still active when I serialize the ksession.
 I tried ksession.halt() before serialization, but with no effect.

 Any ideas?

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users