Flow exception handling
by Swindells, Thomas
Hi Everyone,
I'm trying to get my head round how to use Drools Flow in a reliable manner.
In particular I'm trying to understand how to defensively program against exceptions thrown within Action Nodes (eg NullPointerException).
In 5.0.1 it is absolutely horrendous as if the action throws an exception while being called from fireUntilHalt then the exception just gets swallowed up with no way for the application to detect it at all.
In 5.1.0-M1 it is marginally better in that the exception is thrown through fireUntilHalt (or whatever other location it is called from).
However there seems to be absolutely no way to determine which process is at fault - the process isn't even marked as Aborted and still exists in the session, also if you call fireUntilHalt again it just seems to sit there and not run any more processes. It doesn't even throw an IllegalState type exception to tell you it isn't valid to call it after an exception has occurred.
What I was expecting was that processes work in a similar way to java threads. If a particular process encounters an exception I would expect that:
1. The process is marked as aborted.
2. An appropriate method on a process event listener is called.
3. Any other processes in the session will attempt to continue to run.
Clearly depending on your session configuration the working memory may be in an invalid state and other processes may be stuck waiting for an event to occur which never will, but this is a design decision for the application developer, in many other cases processes will be stand alone keeping all their data internal to themselves.
Is there some other functionality of Drools that I am missing or should I raise a JIRA for this (if one doesn't already exist).
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
14 years, 5 months
Re: [rules-users] Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
by Vijay K Pandey
Update::: Issues related to Plugin. When I recompiled the bpmn2 src and put that jar in the plugin lib, it simply didn't took the recompiled version. Then I removed the jar from the plugin lib and simply copied the - bpmn2 classes directly in the org/drools package of the plugin and voila - plugin started working fine.
Thanks
Vijay
From: Vijay K Pandey
Sent: Tuesday, June 08, 2010 8:48 AM
To: 'Rules Users List'
Subject: RE: Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
Update::: On the exception(mentioned below) related to jar "drools-bpmn2-5.1.0.M2.jar", I recreated this jar file from the Drools source (5.1.0.M2) against JDK6 and the exception went away. :) So far so good.
Plugin related exception is still there. I replaced the jar "drools-bpmn2.jar" which is present in the lib of plugin jar "org.drools.eclipse_5.1.0.M2.jar" with the recompiled jar, but not much luck - plugin is still not able to open the "*.bpmn" process. The error I get is "The method getTextContent() is undefined for the type Node" .
Right now I am at a dead end. Thanks in advance for help.
Thanks
Vijay
From: Vijay K Pandey
Sent: Monday, June 07, 2010 5:45 PM
To: 'Rules Users List'
Subject: RE: Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
I created a sample project to run a very simple rule flow (BPMN process), I got the similar error which the plugin is reporting. My env is SUN JDK 6. Here is the exception I get? Any clue guys.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method getTextContent() is undefined for the type Node
The method getTextContent() is undefined for the type Node
at org.drools.bpmn2.xml.StartEventHandler.handleNode(StartEventHandler.java:46)
at org.drools.bpmn2.xml.AbstractNodeHandler.end(AbstractNodeHandler.java:77)
at org.drools.xml.ExtensibleXmlParser.endElement(ExtensibleXmlParser.java:420)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:180)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:739)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:295)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:174)
at org.drools.compiler.xml.XmlProcessReader.read(XmlProcessReader.java:44)
at org.drools.compiler.ProcessBuilder.addProcessFromFile(ProcessBuilder.java:222)
at org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:415)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:475)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:517)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
Thanks
Vijay
From: Vijay K Pandey
Sent: Sunday, June 06, 2010 11:43 PM
To: Rules Users List
Subject: Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
Hi,
I just downloaded the Drools 5.1.0.M2 (have been using the snapshot version of around 16th April 2010) - created a sample "rule flow file(start-->user task-->end) - bpmn2 version". But when I clicked the file to open it gave the following error (image attached)
"The method getTextContent() is undefined for the type Node" .
I understand this error is related to org.w3c.dom.Node where this method was added as part of DOM Level 3 and available in JDK 5+ . My project and eclipse is configured against JDK 6+ . Not sure why this error with M2.
May be it is because of the drools-bpmn2.jar included in the drools eclipse plugin? Can someone shed some light that where it might be going wrong.
[cid:image001.png@01CB06F6.8568A3E0]
Thanks
Vijay
14 years, 5 months
smooks query
by Fnu Mahalakshmi
Hi,
Can anyone point me towards a good documentation as to how smooks works with drools?
How does smooks transform non-XML(java) data?? I could not understand this part???
Thank you in advance,
M
</pre>
<P><hr size=1></P>
<P><STRONG><font color=green>Please consider the environment before printing this email.</font></STRONG></P>
<P><STRONG>Visit our website at <a href="http://www.nyse.com">http://www.nyse.com</a> <br>
*****************************************************************************
<br>
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.
</STRONG></P><pre>
14 years, 5 months
Re: [rules-users] Multiple Object referencing error
by Fnu Mahalakshmi
Hi,
Sorry about not posting the code. My mistake.
Classes :
public class Room {
private String name
private int number;
// getter and setter methods here
}
public classs Sprinkler {
private Room room;
private boolean on;
// getter and setter methods here
}
public class Fire {
private Room room;
// getter and setter methods here
}
I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}
2. with data of sprinkler and Room {"n/a",r1,"n/a",r3}
I am writing rule " if fire exists in room start sprinkler" { so if f1 and r1 in this case: I should get s1, r1 } But since no sprinkler in r2 , That data should not get outputted.
I want my ouput file to look like:
Name Number
Xyz 1
# xyz is my room name and 1 is the room number : r1(xyz,1) . But I am unable to delete entries.Is there anyway I can do it?
#only this should appears as the other room does not have a sprinkler.
when
Fire($room : room)
$sprinkler : Sprinkler( room == $room, modified == false )
Then
$sprinkler.setmodified(true);
modify( $sprinkler ) { setSprinkle( "s1" ) };
end
Error:
I am getting the error at a place where I am trying to write back from my working memory to my output file.
It is happening because the second rule to turn on the sprinkler does not work and as a result a null value is getting stored.
Is it possible that there can exists 2 different Room() objects with the same room.name ??
Because the room objects are getting stored from different files to the working memory ??
Do you think it better to store room objects in a separate list??
I store all information into a list and load that into the memory.
Am I going wrong here?
Please help.
Thank you.
-M
Please consider the environment before printing this email.
Visit our website at http://www.nyse.com
****************************************************
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.
14 years, 5 months
Exception using persistence
by Robert
Hi, I followed the instructions on setting up the persistence in the
drools flow doc, but I get the following exception:
Exception in thread "main" java.lang.RuntimeException: Could not commit
session
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
at
com.rob.server.core.process.drools.tasks.DroolsProcessHandler.<init>(DroolsProcessHandler.scala:130)
at
com.rob.server.core.process.drools.tasks.StartDroolsProcessHandler$.main(DroolsProcessHandler.scala:33)
at
com.rob.server.core.process.drools.tasks.StartDroolsProcessHandler.main(DroolsProcessHandler.scala)
Caused by: javax.naming.NameNotFoundException; remaining name
'UserTransaction'
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:576)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:663)
at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:678)
at
org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:110)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:109)
... 5 more
I have no idea what this means. I guess SingleSessionCommandService is
looking up for "UserTransaction", but whats the "UserTransaction" ?
Cheers, Rob.
--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
14 years, 5 months
Re: [rules-users] Multiple Object Referencing problem
by Fnu Mahalakshmi
Hi Esteban,
I am getting the error at a place where I am trying to write back from my working memory to my output file.
It is happening because the second rule to turn on the sprinkler does not work and as a result a null value is getting stored.
Is it possible that there can exists 2 different Room() objects with the same room.name ??
Because the room objects are getting stored from different files to the working memory ??
Do you think it better to store room objects in a separate list??
I store all information into a list and load that into the memory.
Am I going wrong here?
Please help.
Thank you.
-M
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of rules-users-request(a)lists.jboss.org
Sent: Tuesday, June 08, 2010 8:40 AM
To: rules-users(a)lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 36
Send rules-users mailing list submissions to
rules-users(a)lists.jboss.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
rules-users-request(a)lists.jboss.org
You can reach the person managing the list at
rules-users-owner(a)lists.jboss.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."
Today's Topics:
1. Re: Multiple Object Referencing problem (Esteban Aliverti)
2. Re: Exception using persistence (Alan.Gairey(a)tessella.com)
----------------------------------------------------------------------
Message: 1
Date: Tue, 8 Jun 2010 09:25:47 -0300
From: Esteban Aliverti <esteban.aliverti(a)gmail.com>
Subject: Re: [rules-users] Multiple Object Referencing problem
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<AANLkTilCFcZwhX6uthWz3tIvkJXdtqVKXcb0uG-rqm91(a)mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
Look at the line 58 of RulesTest class and you will find the problem. Try to
always analyse the stacktrace if there are no drools classes involved, then
it is not a Drools error. And remember, the debugger is your friend ;)
Best,
2010/6/7 David Sinclair <dsinclair(a)chariotsolutions.com>
> This has nothing to do with Drools. It looks like you are giving Writer bad
> input perhaps??
>
> Exception in thread "main" *java.lang.NullPointerException*
>
> at java.io.Writer.write(Unknown Source)
>
> at com.org.RulesTest.main(*RulesTest.java:58*)
>
>
>
>
> 2010/6/7 Fnu Mahalakshmi <FMahalakshmi(a)nyx.com>
>
>> Hi,
>>
>>
>>
>> I am trying out this example from the book :
>>
>> public class Room {
>>
>> private String name
>>
>> // getter and setter methods here
>>
>> }
>>
>> public classs Sprinkler {
>>
>> private Room room;
>>
>> private boolean on;
>>
>> // getter and setter methods here
>>
>> }
>>
>> public class Fire {
>>
>> private Room room;
>>
>> // getter and setter methods here
>>
>> }
>>
>>
>>
>> I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}
>>
>> 2. with data of sprinkler and Room { ? ?, r1; ?
>> ? , r2}
>>
>>
>>
>> I am writing rule ? if fire exists in room start sprinkler? { so if f1 and
>> r1 in this case: I should get s1, r1 }
>>
>> when
>>
>> Fire($room : room)
>>
>> $sprinkler : Sprinkler( room == $room, modified == false )
>>
>> Then
>>
>> $sprinkler.setmodified(true);
>>
>> modify( $sprinkler ) { setSprinkle( ?s1? ) };
>>
>> end
>>
>>
>>
>> But this gives me error:
>>
>> Exception in thread "main" *java.lang.NullPointerException*
>>
>> at java.io.Writer.write(Unknown Source)
>>
>> at com.org.RulesTest.main(*RulesTest.java:58*)
>>
>>
>>
>> From what I observed this rule is not getting fired at all.
>>
>> I want this rule to be fired on the data in my second input file.
>>
>> The rules for my first input file get executed properly.
>>
>>
>>
>> Can any1 tell me where I am going wrong??
>>
>> Is there any way in which we can use the modified data { after rules are
>> fired on the first input data and it is modified}to fire another set of
>> rules on the same input depending on the next input file???
>>
>>
>>
>> Thank you.
>>
>>
>>
>> -M
>>
>> ------------------------------
>>
>> *Please consider the environment before printing this email.*
>>
>> *Visit our website at http://www.nyse.com
>> *****************************************************************************
>>
>> Note: The information contained in this message and any attachment to it
>> is privileged, confidential and protected from disclosure. If the reader of
>> this message is not the intended recipient, or an employee or agent
>> responsible for delivering this message to the intended recipient, you are
>> hereby notified that any dissemination, distribution or copying of this
>> communication is strictly prohibited. If you have received this
>> communication in error, please notify the sender immediately by replying to
>> the message, and please delete it from your system. Thank you. NYSE
>> Euronext. *
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
14 years, 5 months
Re: [rules-users] Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
by Vijay K Pandey
Update::: On the exception(mentioned below) related to jar "drools-bpmn2-5.1.0.M2.jar", I recreated this jar file from the Drools source (5.1.0.M2) against JDK6 and the exception went away. :) So far so good.
Plugin related exception is still there. I replaced the jar "drools-bpmn2.jar" which is present in the lib of plugin jar "org.drools.eclipse_5.1.0.M2.jar" with the recompiled jar, but not much luck - plugin is still not able to open the "*.bpmn" process. The error I get is "The method getTextContent() is undefined for the type Node" .
Right now I am at a dead end. Thanks in advance for help.
Thanks
Vijay
From: Vijay K Pandey
Sent: Monday, June 07, 2010 5:45 PM
To: 'Rules Users List'
Subject: RE: Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
I created a sample project to run a very simple rule flow (BPMN process), I got the similar error which the plugin is reporting. My env is SUN JDK 6. Here is the exception I get? Any clue guys.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method getTextContent() is undefined for the type Node
The method getTextContent() is undefined for the type Node
at org.drools.bpmn2.xml.StartEventHandler.handleNode(StartEventHandler.java:46)
at org.drools.bpmn2.xml.AbstractNodeHandler.end(AbstractNodeHandler.java:77)
at org.drools.xml.ExtensibleXmlParser.endElement(ExtensibleXmlParser.java:420)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:180)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:739)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:295)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:174)
at org.drools.compiler.xml.XmlProcessReader.read(XmlProcessReader.java:44)
at org.drools.compiler.ProcessBuilder.addProcessFromFile(ProcessBuilder.java:222)
at org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:415)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:475)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:517)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
Thanks
Vijay
From: Vijay K Pandey
Sent: Sunday, June 06, 2010 11:43 PM
To: Rules Users List
Subject: Drools 5.1.0.M2 - BPMN2 process issue - Eclipse plugin. -- The method getTextContent() is undefined for the type Node
Hi,
I just downloaded the Drools 5.1.0.M2 (have been using the snapshot version of around 16th April 2010) - created a sample "rule flow file(start-->user task-->end) - bpmn2 version". But when I clicked the file to open it gave the following error (image attached)
"The method getTextContent() is undefined for the type Node" .
I understand this error is related to org.w3c.dom.Node where this method was added as part of DOM Level 3 and available in JDK 5+ . My project and eclipse is configured against JDK 6+ . Not sure why this error with M2.
May be it is because of the drools-bpmn2.jar included in the drools eclipse plugin? Can someone shed some light that where it might be going wrong.
[cid:image001.png@01CB06E7.1655B9C0]
Thanks
Vijay
14 years, 5 months
help
by ron riley
help
rules-users-request(a)lists.jboss.org wrote:
> Send rules-users mailing list submissions to
> rules-users(a)lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.jboss.org/mailman/listinfo/rules-users
> or, via email, send a message with subject or body 'help' to
> rules-users-request(a)lists.jboss.org
>
> You can reach the person managing the list at
> rules-users-owner(a)lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of rules-users digest..."
>
>
> Today's Topics:
>
> 1. FW: how to fire a subset of rules in KB? (John Peterson)
> 2. Re: Multiple Object Referencing problem (Fnu Mahalakshmi)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 8 Jun 2010 05:54:39 -0700
> From: "John Peterson" <john.peterson.gv3k(a)statefarm.com>
> Subject: [rules-users] FW: how to fire a subset of rules in KB?
> To: <rules-users(a)lists.jboss.org>
> Message-ID:
> <D3A6E68928C9104BB815C83F43A36BDF0DA1F23A(a)WPSCV6NH.OPR.STATEFARM.ORG>
> Content-Type: text/plain; charset="us-ascii"
>
> Date: Mon, 7 Jun 2010 17:28:12 +0800
> From: "wenjinchao" <wenjinchao0418(a)gmail.com>
> Subject: [rules-users] how to fire a subset of rules in KB?
> To: "rules-users" <rules-users(a)lists.jboss.org>
> Message-ID: <201006071728086572085(a)gmail.com>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi all,
>
> I'm a newbie for drools.
> And i want to know how to fire a subset of rules in KB, suppose there
> are three rules named A,B,C, and I want to fire rule A only.
>
>
>
> by the way,
> suppose there is a drl file containing rule, and i have set up KB, and
> call fireAllRules through statefulKnowledgeSession. After that, the rule
> file is changed, how to load rules dynamicly?
>
> Is there any solution?
> Thanks in advance!
>
>
> best regards.
>
>
> 2010-06-07
>
>
>
> Wenjinchao
>
>
>
> Hi,
>
> I'll take a crack at you first question....
>
> Check out Agenda Filters:
>
> http://legacy.drools.codehaus.org/Agenda
>
> The example listed is using Rule Names, but you can use the following to
> look at Meta Attribute values instead:
>
> AgendaFilter filter = new AgendaFilter() {
>
> @Override
> public boolean accept(Activation activation) {
>
> // Filter out rule Hello World from Sample.drl for execution
> if (activation.getRule().getMetaAttribute("Purpose").equals("Print
> Hello
> World")) {
> return true;
> }
> return false;
> }
> };
>
> On your rules, you'll want to add a meta attribute for groups A, B, and
> C. Here's an example:
>
> rule "Hello World"
> @Purpose(Print Hello World) <--- THIS IS YOUR META-ATTRIBUTE
> when
> m : Message( status == Message.HELLO, myMessage :
> message )
> then
> System.out.println( myMessage );
> m.setMessage( "Goodbye cruel world" );
> m.setStatus( Message.GOODBYE );
> update( m );
> end
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 8 Jun 2010 09:28:04 -0400
> From: Fnu Mahalakshmi <FMahalakshmi(a)nyx.com>
> Subject: Re: [rules-users] Multiple Object Referencing problem
> To: "'rules-users(a)lists.jboss.org'" <rules-users(a)lists.jboss.org>
> Message-ID:
> <994758E35590274E955FA75763C5AA5002D01086(a)MTEXMBXP01.ad.NYX.com>
> Content-Type: text/plain; charset="us-ascii"
>
>
> Hi Esteban,
>
> I am getting the error at a place where I am trying to write back from my working memory to my output file.
> It is happening because the second rule to turn on the sprinkler does not work and as a result a null value is getting stored.
> Is it possible that there can exists 2 different Room() objects with the same room.name ??
> Because the room objects are getting stored from different files to the working memory ??
> Do you think it better to store room objects in a separate list??
> I store all information into a list and load that into the memory.
> Am I going wrong here?
>
> Please help.
>
> Thank you.
> -M
> -----Original Message-----
> From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of rules-users-request(a)lists.jboss.org
> Sent: Tuesday, June 08, 2010 8:40 AM
> To: rules-users(a)lists.jboss.org
> Subject: rules-users Digest, Vol 43, Issue 36
>
> Send rules-users mailing list submissions to
> rules-users(a)lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.jboss.org/mailman/listinfo/rules-users
> or, via email, send a message with subject or body 'help' to
> rules-users-request(a)lists.jboss.org
>
> You can reach the person managing the list at
> rules-users-owner(a)lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of rules-users digest..."
>
>
> Today's Topics:
>
> 1. Re: Multiple Object Referencing problem (Esteban Aliverti)
> 2. Re: Exception using persistence (Alan.Gairey(a)tessella.com)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 8 Jun 2010 09:25:47 -0300
> From: Esteban Aliverti <esteban.aliverti(a)gmail.com>
> Subject: Re: [rules-users] Multiple Object Referencing problem
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Message-ID:
> <AANLkTilCFcZwhX6uthWz3tIvkJXdtqVKXcb0uG-rqm91(a)mail.gmail.com>
> Content-Type: text/plain; charset="windows-1252"
>
> Look at the line 58 of RulesTest class and you will find the problem. Try to
> always analyse the stacktrace if there are no drools classes involved, then
> it is not a Drools error. And remember, the debugger is your friend ;)
>
> Best,
>
> 2010/6/7 David Sinclair <dsinclair(a)chariotsolutions.com>
>
>> This has nothing to do with Drools. It looks like you are giving Writer bad
>> input perhaps??
>>
>> Exception in thread "main" *java.lang.NullPointerException*
>>
>> at java.io.Writer.write(Unknown Source)
>>
>> at com.org.RulesTest.main(*RulesTest.java:58*)
>>
>>
>>
>>
>> 2010/6/7 Fnu Mahalakshmi <FMahalakshmi(a)nyx.com>
>>
>>> Hi,
>>>
>>>
>>>
>>> I am trying out this example from the book :
>>>
>>> public class Room {
>>>
>>> private String name
>>>
>>> // getter and setter methods here
>>>
>>> }
>>>
>>> public classs Sprinkler {
>>>
>>> private Room room;
>>>
>>> private boolean on;
>>>
>>> // getter and setter methods here
>>>
>>> }
>>>
>>> public class Fire {
>>>
>>> private Room room;
>>>
>>> // getter and setter methods here
>>>
>>> }
>>>
>>>
>>>
>>> I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}
>>>
>>> 2. with data of sprinkler and Room { ? ?, r1; ?
>>> ? , r2}
>>>
>>>
>>>
>>> I am writing rule ? if fire exists in room start sprinkler? { so if f1 and
>>> r1 in this case: I should get s1, r1 }
>>>
>>> when
>>>
>>> Fire($room : room)
>>>
>>> $sprinkler : Sprinkler( room == $room, modified == false )
>>>
>>> Then
>>>
>>> $sprinkler.setmodified(true);
>>>
>>> modify( $sprinkler ) { setSprinkle( ?s1? ) };
>>>
>>> end
>>>
>>>
>>>
>>> But this gives me error:
>>>
>>> Exception in thread "main" *java.lang.NullPointerException*
>>>
>>> at java.io.Writer.write(Unknown Source)
>>>
>>> at com.org.RulesTest.main(*RulesTest.java:58*)
>>>
>>>
>>>
>>> From what I observed this rule is not getting fired at all.
>>>
>>> I want this rule to be fired on the data in my second input file.
>>>
>>> The rules for my first input file get executed properly.
>>>
>>>
>>>
>>> Can any1 tell me where I am going wrong??
>>>
>>> Is there any way in which we can use the modified data { after rules are
>>> fired on the first input data and it is modified}to fire another set of
>>> rules on the same input depending on the next input file???
>>>
>>>
>>>
>>> Thank you.
>>>
>>>
>>>
>>> -M
>>>
>>> ------------------------------
>>>
>>> *Please consider the environment before printing this email.*
>>>
>>> *Visit our website at http://www.nyse.com
>>> *****************************************************************************
>>>
>>> Note: The information contained in this message and any attachment to it
>>> is privileged, confidential and protected from disclosure. If the reader of
>>> this message is not the intended recipient, or an employee or agent
>>> responsible for delivering this message to the intended recipient, you are
>>> hereby notified that any dissemination, distribution or copying of this
>>> communication is strictly prohibited. If you have received this
>>> communication in error, please notify the sender immediately by replying to
>>> the message, and please delete it from your system. Thank you. NYSE
>>> Euronext. *
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
>
14 years, 5 months
FW: how to fire a subset of rules in KB?
by John Peterson
Date: Mon, 7 Jun 2010 17:28:12 +0800
From: "wenjinchao" <wenjinchao0418(a)gmail.com>
Subject: [rules-users] how to fire a subset of rules in KB?
To: "rules-users" <rules-users(a)lists.jboss.org>
Message-ID: <201006071728086572085(a)gmail.com>
Content-Type: text/plain; charset="us-ascii"
Hi all,
I'm a newbie for drools.
And i want to know how to fire a subset of rules in KB, suppose there
are three rules named A,B,C, and I want to fire rule A only.
by the way,
suppose there is a drl file containing rule, and i have set up KB, and
call fireAllRules through statefulKnowledgeSession. After that, the rule
file is changed, how to load rules dynamicly?
Is there any solution?
Thanks in advance!
best regards.
2010-06-07
Wenjinchao
Hi,
I'll take a crack at you first question....
Check out Agenda Filters:
http://legacy.drools.codehaus.org/Agenda
The example listed is using Rule Names, but you can use the following to
look at Meta Attribute values instead:
AgendaFilter filter = new AgendaFilter() {
@Override
public boolean accept(Activation activation) {
// Filter out rule Hello World from Sample.drl for execution
if (activation.getRule().getMetaAttribute("Purpose").equals("Print
Hello
World")) {
return true;
}
return false;
}
};
On your rules, you'll want to add a meta attribute for groups A, B, and
C. Here's an example:
rule "Hello World"
@Purpose(Print Hello World) <--- THIS IS YOUR META-ATTRIBUTE
when
m : Message( status == Message.HELLO, myMessage :
message )
then
System.out.println( myMessage );
m.setMessage( "Goodbye cruel world" );
m.setStatus( Message.GOODBYE );
update( m );
end
14 years, 5 months
Multiple Object Referencing problem
by Fnu Mahalakshmi
Hi,
I am trying out this example from the book :
public class Room {
private String name
// getter and setter methods here
}
public classs Sprinkler {
private Room room;
private boolean on;
// getter and setter methods here
}
public class Fire {
private Room room;
// getter and setter methods here
}
I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}
2. with data of sprinkler and Room { " ", r1; " " , r2}
I am writing rule " if fire exists in room start sprinkler" { so if f1 and r1 in this case: I should get s1, r1 }
when
Fire($room : room)
$sprinkler : Sprinkler( room == $room, modified == false )
Then
$sprinkler.setmodified(true);
modify( $sprinkler ) { setSprinkle( "s1" ) };
end
But this gives me error:
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at com.org.RulesTest.main(RulesTest.java:58)
>From what I observed this rule is not getting fired at all.
I want this rule to be fired on the data in my second input file.
The rules for my first input file get executed properly.
Can any1 tell me where I am going wrong??
Is there any way in which we can use the modified data { after rules are fired on the first input data and it is modified}to fire another set of rules on the same input depending on the next input file???
Thank you.
-M
</pre>
<P><hr size=1></P>
<P><STRONG><font color=green>Please consider the environment before printing this email.</font></STRONG></P>
<P><STRONG>Visit our website at <a href="http://www.nyse.com">http://www.nyse.com</a> <br>
*****************************************************************************
<br>
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.
</STRONG></P><pre>
14 years, 5 months