[fusion] weird race conditions and a null pointer exception
by burmanator
I am running 2 rules that are very similar but with a slight change:
rule One
when
$foo : Foo($name : Name, $msg : Message !="")
$prev : ArrayList(size<1) from collect( Foo(Name==$name, Message == $msg,
this before $foo)
$list : Set(size>0) from accumulate( Foo(Name == $name, $msgs: Message !=
$msg, this after $foo), collectSet($msgs))
then
System.out.println($name + "\twent from \"" + $msg + "\"\tto " + $list);
end
rule Two
when
$foo : Foo($name : Name, $msg : Message !="")
Not( Foo(Name==$name, Message == $msg, this before $foo))
$list : Set(size>0) from accumulate( Foo(Name == $name, $msgs: Message !=
$msg, this after $foo), collectSet($msgs))
then
System.out.println($name + "\twent A from \"" + $msg + "\"\tto " + $list);
end
rule One works just fine however its rule Two I seem to be having trouble
with. In my main method I have an initial print statement, then I go through
this whole process of parsing XML files into objects and then adding those
objects into the session. Once all the objects are entered I do a print out,
I then call fireAllRules on the session and then do another print out.
When I use rule Two, my program starts firing the rules and displaying their
results almost immediately, even before the 2nd print out (sometimes even
before the first initial print out). Most of the time I get a Null Pointer
Exception but it does occasionally finish running. In the cases it does
finish it spits out the output from most of the rules then displays the 2nd
printout, the print out from a rule and then the ending print out. When it
does throw the null pointer exception I get:
java.lang.NullPointerException
at org.drools.core.util.LinkedList.remove(LinkedList.java:133)
at
org.drools.common.DefaultAgenda.addActivation(DefaultAgenda.java.446)
at
org.drools.common.DefaultAgenda.modifyActivation(DefaultAgenda.java:382)
at
org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:301)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:259)
at
org.drools.reteoo.AccumulateNode.exaluateResultConstraints(AccumulateNode.java:676)
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:590)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextimple:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:355)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.imp.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at test2.Engine2.main(Engine2.java:80)
However sometimes when it throws the Null pointer exception, it prints out
some of the results of the rules in the middle of the display of the
exception, such as:
java.lang.NullPointerExceptionName1 went A from "msg1" to [msg2]
Name2 went A from "msg1" to [msg2]
at org.drools.core.util.LinkledList.remove(LinkedList.java.133)
and you know the rest.
When I run both rules together, for some reason it seems to run rule One
over the same name and message pair multiple times even though based on the
logic it should only run it based on the first occurrence.
Also I don't know if this matters but there are 361,694 objects that are
entered into the session, 44,269 of which are Foo objects
--
View this message in context: http://drools.46999.n3.nabble.com/fusion-weird-race-conditions-and-a-null...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
Exception when using retract
by Weiss, Wolfgang
Hi all!
I noticed problems when using retract in rules. Thereby, I get sometimes NullPointerExceptions like this (Drools Version 6.0.0.Beta1):
Exception executing consequence for rule "rule 6 - ts filter" in test: java.lang.NullPointerException
at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1409)
at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1328)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1546)
at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:637)
at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:601)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:233)
at test.DroolsMain.insertEvent(DroolsMain.java:50)
at test.EventSender.run(EventSender.java:73)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at org.drools.core.util.index.LeftTupleIndexHashTable.remove(LeftTupleIndexHashTable.java:381)
at org.drools.core.reteoo.NotNode.retractLeftTuple(NotNode.java:301)
at org.drools.core.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:261)
at org.drools.core.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractRightTuple(CompositeLeftTupleSinkAdapter.java:172)
at org.drools.core.reteoo.JoinNode.retractRightTuple(JoinNode.java:181)
at org.drools.core.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:344)
at org.drools.core.reteoo.EntryPointNode.retractObject(EntryPointNode.java:406)
at org.drools.core.common.NamedEntryPoint.delete(NamedEntryPoint.java:591)
at org.drools.core.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:429)
at test.Rule_rule_6___ts_filter247591339.defaultConsequence(Rule_rule_6___ts_filter247591339.java:18)
at test.Rule_rule_6___ts_filter247591339DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at test.Rule_rule_6___ts_filter247591339DefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1399)
... 8 more
Or, using Drools 5.5.1-SNAPSHOT
Exception executing consequence for rule "rule 3 - remove start stop fact" in test: java.lang.NullPointerException
at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1291)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1215)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1450)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at test.DroolsMain.insertEvent(DroolsMain.java:50)
at test.EventSender.run(EventSender.java:73)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:419)
at test.Rule_rule_3___remove_start_stop_fact.defaultConsequence(Rule_rule_3___remove_start_stop_fact.java:8)
at test.Rule_rule_3___remove_start_stop_factDefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at test.Rule_rule_3___remove_start_stop_factDefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1281)
... 8 more
The problematic rules mostly look something like this:
rule "rule 6 - ts filter"
agenda-group "evaluation"
when
$evtA : Event(type == EventType.START) from entry-point "InputStream"
$evtB : Event(type == EventType.START, this after $evtA, this != $evtA, senderId == $evtA.senderId) from entry-point "InputStream"
then
//do something
//...
retract($evtA);
end
The exception does not immediately occur. Sometimes it occurs sooner, sometimes it takes longer until it occurs. When the exception is thrown, it looks like that the event is not removed from the knowledge base (I watch the number of events in the knowledge base - fact count). I made the experience that this problem only occurs when the rule file grows (e.g. when there are more than 10 rules to execute) and when the load increases. To work temporarily around this problem, I set the java process to use only 1 processor in the windows task manager - which looks like this is a multi threading issue.
I can reproduce this exception with the Drools versions 5.5.0, 5.5.1-SNAPSHOT and 6.0.0.Beta1. I did not test the previous versions explicitly.
Please find attached a small dummy test application to reproduce this problem. Execute therefore the main method from the class "test.DroolsMain". Depending on your machine and load, the problem occurs sometimes sooner or sometimes later. Or, you might notice some other exception, but the problem when retracting events or facts is currently the biggest one in my productive applications.
Best regards,
Wolfgang
12 years, 11 months
Getting Started with an simple sample
by Stefan Schuster
Hello,
I’m still in the phase of learning the basics with drools. Therefor I
created a simplified problem that I try to realize it with drools:
I have several detectors, each of them measures something and converts it
into an integer value between 1 one 6. Every Minute a new measurement is
performed.
When a detector reaches a value of 5 or above, a textfile is created with
the name of the detector as filename and a predefined text as content. When
the detector reaches a value of 3 or less, the texfile is deleted.
My problem is that I’m still “thinking in java” and not yet “thinking in
drools”.
I guess the measured values would be facts that I insert (like the
key-pressed events in the pong-example) to the knowledgebase. But now I
stumble, I have no idea how to continue. Could anyone give me a helping
hand for the next steps?
Thanks in advance
Stefan
12 years, 11 months
How to Compute against WorkingMemory in Drools ?
by vr
I have been looking at the following scenario
1. Alerts are generated by an enterprise system and Sent to the Rule Engine
in batches.
2. I must check the alert batch for possible correlation between the alerts
based on Rules defined in my Rule file (.drl)
*3. Verify if any Correlation already exists for the alerts received if yes
update that correlation with fresh alert data*
4. if no correlation exists i do nothing.
5. If a Correlation exists and No correlation is present in RE representing
the same for those group of alerts I create a New Correlation and update the
RE.
*Steps 1 to 3 are repeated every 15 seconds in the system,*
How do I keep the Objects in Drools to keep checking for Correlation
scenarios as and when I receive data from the enterprise system at regular
intervals so that i can update existing correlation as metioned at *Step 3*
Any approach or suggestion would be very helpful.
-----
Thanks for the support ...!!!
VR
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-Compute-against-WorkingMemory-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
Drools 5.4: How to use functions and clauses
by vr
Hi All,
I am new to Drools and the RE concept and I have the following Rule
defined in my *.drl* file in Eclipse.
*Requirement:*
I want to be able to fetch the Alert List from the Alert Object
and if the alert source attribute is the same i want to combine
multiple alerts present in the List
stated below into a single Unique alert based on some checks
rule "Correlate"
when
$alert : Alert()
$list : Alert ( sourceName=="NETWORK NAME") from $alert.alerts
///alerts is a ArrayList of Alert Objects/
then
checkForMoreStuff($list); /// I passes each alert to the
function or something not sure...?/ end
function void checkForMoreStuff(Alert alert) { // Not sure if this is
required }
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-4-How-to-use-functions-and-cla...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
How to hold a Collection of Objects in memory for processing ?.
by vr
Hi All,
This is the rule defined in my drl file
rule "Entry"
salience 10
when
$alert : Alert()
$list : Alert ( sourceName=="DATA") from $alert.alerts // 1.
Iterate over List of ALerts
then
checkForAlertDescription($list); // 2. I am passing one Alert per
match
end
Is there a way to hold the *Entire List at Step one * in the Drools Memory
so that i can take the Entire list for processing with in the function
defined at Step 2
Instead of the single alert that i have at the moment
Any suggestions would be helpful.
Drools v 5.4.0 Final
-----
Thanks for the support ...!!!
VR
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-hold-a-Collection-of-Objects-in-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
Maintain assets synchronized between members of a team
by ciberg2
Hi,
My Drools project is going well and now it's time for some people starting
creating and deploying new Excel decision tables onto the repository.
For that we are using the Eclipse plugin, I've created a general project
that replicates the package structure so everyone can start deploying these
new tables.
My problem is maintaining all the projects in each team member computer
synchronized. Using Eclipse Tools I can commit and update existing assets
but I've not found a way to get all the new assets not existing in the local
computer.
The only way is getting resources from repository but that has to be done
one by one which is not an ideal way to do it because there will be many,
and to add to the problem doing that the downloaded excel files lose all
formatting and become corrupted.
I thought of using GIT to synch all the files but it seems silly to have to
put the files in a new repository when I already have them in one (Guvnor).
What do you think will be the best way to guarantee that all team members
have the same versions of the assests on their local computers?
--
View this message in context: http://drools.46999.n3.nabble.com/Maintain-assets-synchronized-between-me...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
[planner] documentation
by Eric Keller
Hi everyone,
I am going through your new optaPlanner User Guide documentaiton and found
one typo:
Let's take a look look at 2 different implementations:
(double look!)
2.1.7.1. Simple Java score configuration
Regards
--
Eric
12 years, 11 months
error when deploying guvnor war on websphere
by ashish6276
Hi i am getting this error when i am deploying guvnor war on websphere server
[4/24/13 11:07:10:629 IST] 0000001e webapp I
com.ibm.ws.webcontainer.webapp.WebApp log SRVE0296E:
[guvnorWAS_war#guvnorWAS.war][/test][Servlet.LOG]:.Exception while
dispatching incoming RPC
call:.com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract org.drools.guvnor.client.rpc.UserSecurityContext
org.drools.guvnor.client.rpc.SecurityService.getCurrentUser()' threw an
unexpected exception: java.lang.IllegalStateException: CDI hasn't been
properly started.
Make sure your IDE classpath is in sync with the real maven classpath.
The classpath should include weld-servlet.
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1583)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:870)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:863)
at
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:182)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
Caused by: java.lang.IllegalStateException: CDI hasn't been properly
started.
Make sure your IDE classpath is in sync with the real maven classpath.
The classpath should include weld-servlet.
at
org.drools.guvnor.server.SecurityServiceServlet.getCurrentUser(SecurityServiceServlet.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
The war get deployed in was succesfully. after that when i am hitting the
url from ide the page goes blank and it give me those exception. please help
me .
--
View this message in context: http://drools.46999.n3.nabble.com/error-when-deploying-guvnor-war-on-webs...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
Fusion: Null pointer exception when using sliding windows
by burmanator
I am getting a null pointer exception when I try and use a sliding window.
The rule I'm trying to run is:
$primary : Foo($name : Name) over window length(24)
$prev : ArrayList(size<1) from collect ( Foo(Name == $name, this before
$primary))
I am trying to look at the last 24 Foo events and have the rule only trigger
when an event with that name hasn't been seen before. I also get a null
pointer when I try and do a time window and no Foo events happen within the
window. Shouldn't the rule just not fire?
--
View this message in context: http://drools.46999.n3.nabble.com/Fusion-Null-pointer-exception-when-usin...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months