Newbie: Why Only One Rule Firing
by Greg.Zoller@aviall.com
Hello,
Silly newbie question. I'm trying to write my first rule set to handle
permissions and I'm running into a problem where Drools is not executing
the 'then' clause of all my rules, even though they all resolve to true.
Here's my sample file:
rule "Docs1"
activation-group "permissions"
no-loop true
when
Resources( $resList : resourceList )
$res : Resource(name=="CUSTOMER", allowed==false) from
$resList
then
System.out.println("Foo");
end
rule "Docs2"
activation-group "permissions"
no-loop true
when
Resources( $resList : resourceList )
$res : Resource(name=="INVOICES", allowed==false) from
$resList
then
System.out.println("Wow");
end
I'm using a StatelessKnowledgeSession something like this:
ArrayList ruleObjs = new ArrayList();
ruleObjs.add(resources);
kbase.newStatelessKnowledgeSession().execute(ruleObjs);
So here's my problem. Both of the rules above resolve to true. But only
"Wow" is output to the console. If I comment out the Docs2 rule entirely
then "Foo" is output to the console (proving it also resolves true).
Why wouldn't I get "Wow" and "Foo" output to the console (in no particular
order) when both are run?
To see whether both rules are actually being evaluated I also tried
creating a simple message function that prints something to the console
and returning true. Then I eval() my function as the last line of the when
clause in Docs1. "Wow" from Docs2 is output as before, as is my
function's message (proving that Docs1 was evaluated and resolved
truthfully), but... Docs1 'then' clause is not executed and Foo is not
output. Why?
This scenario holds true if I have lots of rules. Only the 'then' clause
of last one resolved true is executed even though there may have been
several other rules that resolved true.
Thanks in advance for any ideas or help!
Best regards,
Greg
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
This e-mail message, including attachments, may contain confidential,
proprietary, or export controlled information.
Any unauthorized disclosure, distribution, or other use is prohibited,
unless expressly authorized.
If you receive this e-mail in error, please notify the sender, and delete
all copies of the original message from your systems.
16 years, 1 month
The Eclipse JDT Core jar is not in the classpath
by ahrimann@gmail.com
Hi, I try to create Eclipse RCP & use drools.
Eclipse Galileo: Build id: 20100218-1602 ( Eclipse for RCP/Plug-in Developers)
Drools 5.0 downloaded with the eclipse plugin from official site.
If I create JavaApplication I have to add org.eclipse.jdt.core*.jar by
myself in the build path... but it works.
If I create RCP-Application I become all the time this error:
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274)
at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:142)
at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilder(KnowledgeBuilderProviderImpl.java:29)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:29)
at de.intranda.qtitest.model.DroolsEvaluator.readKnowledgeBase(DroolsEvaluator.java:81)
at de.intranda.qtitest.model.DroolsEvaluator.getNewItemRef(DroolsEvaluator.java:56)
at de.intranda.qtitest.model.DroolsEvaluator.setNextItemRef(DroolsEvaluator.java:38)
at de.intranda.qtitest.gui.TestView.loadNextItem(TestView.java:224)
at de.intranda.qtitest.gui.TestView.access$3(TestView.java:220)
at de.intranda.qtitest.gui.TestView$1.widgetSelected(TestView.java:159)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at de.intranda.qtitest.Application.start(Application.java:27)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not
in the classpath
at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:94)
at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270)
... 39 more
I've added eclipse.core.jdt* as dependency in plugin & product. I've
added it to the build path ... but it just doesn't work :(
Please help :)
16 years, 1 month
Fwd: Double Handling
by Edson Tirelli
Sorry, I meant to send this to the list.
Ade, let us know if that solves the problem.
Edson
---------- Forwarded message ----------
From: Edson Tirelli <tirelli(a)post.com>
Date: 2010/4/15
Subject: Re: [rules-users] Double Handling
To: Ade Timi <adeyinka.timi(a)nathean.com>
Ade,
There you go:
https://jira.jboss.org/jira/browse/JBRULES-2424
You have:
public String setErrorMessage() {
This problem was fixed in M2 (trunk). Meanwhile, you can rename your
method or use a trunk snapshot.
Edson
16 years, 1 month
How to do Exception Handling???
by nanic23
I have a ruleflow that handles exceptions when they are raised by a "Fault"
node but I am not being able to accomplish the same if an exception is
thrown by a workItem or an action node instead.
I have a workItem node with a work item handler that throws a
RuntimeException. My exception handler in the composite node is not catching
this exception.
So, question
1) how can I handle runtime exceptions thrown by my workItemHandlers?
2) how can I get a hold of the exception to log the stack trace?
Any ideas or tips are very appreciated.
Nick.
--
View this message in context: http://n3.nabble.com/How-to-do-Exception-Handling-tp689387p689387.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 1 month
From RuleAgent to KnowledgeAgent
by Luiz Eduardo Guida Valmont
Hi all,
Recently I had to update part of the application I'm working so it would use
KnowledgeAgent instead of RuleAgent. The later restricts scanned DRL files
so that all rules from any given package must be written into only one
file), whereas the former does not. Long story made short: an external
application will feed my application with generated DRL's and it cannot (aka
will not) managed a single monolithic DRL or even regenerate it every now
and then.
What happens is that I have to update (re-write?) a less critical part of
that code which generates a list of all rules contained within a certain
package. It has to print rules' attibutes like name, salience,
date-effective and date-expires. On the one hand, the old code imports *
org.drools.rule.Rule* (1), which provides getters for such properties; that
Rule class is accessed through a chain of method calls starting at
RuleAgent, for example:
agent.getRuleBase().getPackage( /* ... */ ).getRules()[ /* ... */
> ].getDateEffective()
>
On the other hand, when using KnowledgeAgent's, I can fetch instances of *
org.drools.definition.rule.Rule* through a
similar-but-effectivelly-different chain of method calls, like so:
agent.getKnowledgeBase().getKnowledgePackage( /* ... */ ).getRules()
>
This one getRules returns a *Collection* of *org.drools.definition.rule.Rule
* (2). Finally, this class does not provide similar methods:
String getPackageName
String getName
Collection listMetaAttributes
String getMetaAttribute
>
Hoping I've made myself clear up to this point, I ask: is it posible to
convert an instance of (1) into an instance of (2) or is it possible to get
instances of (1) through getters starting at KnowledgeAgent?
Thanks in advance,
Luiz Valmont
16 years, 1 month
Drools flow definitions
by rudolf michael
Hello there,
After installing Drools and playing around with the KnowledgeBase and
sessions, i was able to do a proof of concept to act as a Workflow Engine.
It seems this is a good engine with lots of features included.
I am still a newbie, what i couldnt find though is the Drools flow/xml
definitions not being persisted in the db.
How can i list my deployed flow/xml definitions?
best regards,
Rudolf Michael
16 years, 1 month
Resuming Flow: NPE when completing a work item
by nanic23
Hi,
I found this question repeated three times on this user list without any
answers. I would, however, appreciate one.
We have a point where the flow reached a wait state and suspended. Now
we are resuming the flow [by running a different test] and trying to
complete the work item, as it is suggested by some posts on this user list.
However we are getting a Null Pointer Exception here [ at
org.drools.marshalling.impl.MarshallerReaderContext.resolveClass(MarshallerReaderContext.java:78)
].
If you have any ideas, it would be helpful.
Thank you.
// COMPLETING WORK ITEM:
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(
rwi.getSessionId(), knowledgeBase, null, env );
registerWorkItemHandlers((WorkItemManager) ksession
.getWorkItemManager(), ksession);
dbLogger = new WorkingMemoryDbLogger( ksession );
ksession.getWorkItemManager().completeWorkItem( rwi.getWorkItemId(), null
);
// EXCEPTION:
java.lang.NullPointerException
at
org.drools.marshalling.impl.MarshallerReaderContext.resolveClass(MarshallerReaderContext.java:78)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at
org.drools.marshalling.impl.InputMarshaller.readWorkItem(InputMarshaller.java:829)
at
org.drools.persistence.processinstance.WorkItemInfo.getWorkItem(WorkItemInfo.java:86)
at
org.drools.persistence.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:90)
at
org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:46)
at
org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:12)
at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:118)
at
com.jpmc.admincenter.flow.ApprovalFlowPersistenceTest.shouldResumeFlow(ApprovalFlowPersistenceTest.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
-------- Test Execution Finished --------
--
View this message in context: http://n3.nabble.com/Resuming-Flow-NPE-when-completing-a-work-item-tp7168...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 1 month
Building from source
by nanic23
Hi all,
Could anyone please post a "step-by-step" guide in how to build Drools from
source.
I have never built it from source and I know that there is lot of people out
here that does it.
Something simple and clear.... as a
1.
2.
3.
......
guide.
Thank you very much!!!
Nick.
P.S. I'm doing my homework and investigating as well :)
--
View this message in context: http://n3.nabble.com/Building-from-source-tp722456p722456.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 1 month
Drools on android
by Justin King
Hi All,
I'm wondering if anyone has tried to use drools in a google android
application, and if so what problems did you have? I'd also be interested to
know if its even possible!
Thanks!
--
Regards,
Justin King
PhD Candidate
Faculty of Information and Communication Technologies
Swinburne University of Technology
http://www.ict.swin.edu.au/ictstaff/justinking
16 years, 1 month