<div dir="ltr">Yes.. but you can include these two lines before this, to check.<div><br></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Operator op = BeforeEvaluatorDefinition.BEFORE;</span><br style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">
<span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Operator op = AfterEvaluatorDefinition.AFTER;</span><br></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br>
</span></div><div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">The problem in that, for example, for the before, </span></div><div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br>
</span></div><div style><a href="https://github.com/droolsjbpm/drools/blob/5.5.x/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java#L82">https://github.com/droolsjbpm/drools/blob/5.5.x/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java#L82</a><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br>
</span></div><div style><br></div><div style>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.</div><div style><br></div><div style>
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px"><div class="" id="LC82" style="padding-left:10px;background-color:rgb(255,255,204)">
<span class="" style="font-weight:bold">public</span> <span class="" style="font-weight:bold">static</span> <span class="" style="font-weight:bold">final</span> <span class="">Operator</span> <span class="">BEFORE</span> <span class="" style="font-weight:bold">=</span> <span class="">Operator</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">addOperatorToRegistry</span><span class="" style="font-weight:bold">(</span> <span class="" style="color:rgb(221,17,68)">"before"</span><span class="" style="font-weight:bold">,</span></div>
<div class="" id="LC83" style="padding-left:10px"> <span class="" style="font-weight:bold">false</span> <span class="" style="font-weight:bold">);</span></div>
</pre></div><div style>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.</div>
<div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></span></div><div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Thanks,</span></div>
<div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></span></div><div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Demian</span></div>
<div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></span></div><div style><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Demian</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 11, 2013 at 12:09 PM, Alexander Wolf <span dir="ltr"><<a href="mailto:mail@alexander-wolf.net" target="_blank">mail@alexander-wolf.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hey Demian, </div><div><br></div><div>thank you! This might actually be related. But how do I get the reference to these Operators to (re)set them?</div>
<div><br></div><div>This is my unmarshalling code (pretty simple and basic..):</div><div><br></div><div><div style="margin:0px;font-size:12px;font-family:Monaco">ByteArrayInputStream bais = <span style="color:#931a68">new</span> ByteArrayInputStream(<span style="color:#0326cc">serializedKnowledgeBase</span>);</div>
<div style="margin:0px;font-size:12px;font-family:Monaco">ObjectInputStream ois = <span style="color:#931a68">new</span> ObjectInputStream(bais);</div><div style="margin:0px;font-size:12px;font-family:Monaco">kbase = (KnowledgeBase)ois.readObject();</div>
<p style="margin:0px;font-size:12px;font-family:Monaco;min-height:16px"><span style="white-space:pre-wrap">                        </span></p><div style="margin:0px;font-size:12px;font-family:Monaco">Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);</div>
<div style="margin:0px;font-size:12px;font-family:Monaco">ByteArrayInputStream bais2 = <span style="color:#931a68">new</span> ByteArrayInputStream(<span style="color:#0326cc">serializedKnowledgeSession</span>);</div><div style="margin:0px;font-size:12px;font-family:Monaco">
<span style="color:#0326cc">knowledgeSession</span> = marshaller.unmarshall(bais2);</div></div><div><br></div><div>Also: Is this going to be fixed in 5.6.0 ? (@Mark Proctor?)</div><div><br></div><div>- Alex</div><div><div class="h5">
<div><br></div><br><div><div>On 11.10.2013, at 16:09, Demian Calcaprina <<a href="mailto:calcacuervo@gmail.com" target="_blank">calcacuervo@gmail.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr"><div>
Hey Alexander, </div><div><br></div>Would this be related to this?<div><br></div><div><a href="https://issues.jboss.org/browse/DROOLS-243" target="_blank">https://issues.jboss.org/browse/DROOLS-243</a><br></div><div><br>
</div><div>If it is this one, you can do something like this as a workaround before constructing the KBase:</div><div><br></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Operator op = BeforeEvaluatorDefinition.BEFORE;</span><br style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">
<span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Operator op = AfterEvaluatorDefinition.AFTER;</span><br></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br>
</span></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">This will cause the evaluation definition to be put in memory.</span></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br>
</span></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Hope this helps!</span></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br>
</span></div><div><span style="color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Demian</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 11, 2013 at 9:21 AM, Alexander Wolf <span dir="ltr"><<a href="mailto:mail@alexander-wolf.net" target="_blank">mail@alexander-wolf.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Drools 5.5.0 Final]<br>
<br>
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.<br>
<br>
Some time after recreating the session and inserting some events I get the following exception:<br>
<br>
java.lang.NullPointerException: null<br>
at org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:351)<br>
...<br>
<br>
Apparently the exception seems to be related to a rule that uses temporal reasoning.<br>
After getting it once, the session seems to be corrupt -> from now on every time I call ksession.insert(event) the same exception occurs.<br>
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).<br>
When I run the server with the same events/sessions without stopping (serialization/deserialization) the exception does not occur)<br>
<br>
Can I do anything to prevent this behaviour? I thought maybe the "after" timer/trigger is somehow still active when I serialize the ksession.<br>
I tried ksession.halt() before serialization, but with no effect.<br>
<br>
Any ideas?<br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><br></div>
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote>
</div><br></div></div></div><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></blockquote></div><br></div>