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.
14 years, 11 months
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
14 years, 11 months
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
14 years, 11 months
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.
14 years, 11 months
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.
14 years, 11 months
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
14 years, 11 months
Timer node issue when using ksession created with JPAKnowledgeService
by nanic23
Hi all,
I successfully implemented a Timer node and trigger it by doing:
final StatefulKnowledgeSession ksession =
knowledgeBase.newStatefulKnowledgeSession();
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}).start();
But when I've drools persistence in place and use the JPAKnowledgeService to
create the knowledge session the timer doesn't run at all. I checked and the
thread is being spawned but when ksession.fireUntilHalt() is called nothing
happens.
final StatefulKnowledgeSession ksession = JPAKnowledgeService
.newStatefulKnowledgeSession(knowledgeBase, null, env);
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}).start();
Environment looks like this:
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
I am trying different things but haven't been able to make it work yet.
So, the question is: Can I run a timer when having drools persistence in
place? If yes, how can I achive this?
Any tips and/or ideas are appreciated.
Thanks,
Nick.
P.S. I "kind" of answered my own questions but I have some other new
questions :) Please keep reading below!
---------------------------------------------
I was able to fire the timer when having drools persistence in place using
ksession created with JPAKnowledgeService. I got it running by calling
ksession.fireAllRules() instead of ksession.fireUntilHalt();
QUESTIONS:
a. is it ok to fire a timer by calling fireAllRules()?
b. should we still be able to fire the timer with fireUntilHalt() in this
situation?
c. are there any difference to be considered when firing with fireAllRules()
vs. fireUntilHalt()?
Thanks,
Nick.
--
View this message in context: http://n3.nabble.com/Timer-node-issue-when-using-ksession-created-with-JP...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
Drools Flow: Problem with constraint in (Wait) State node
by Alan.Gairey@tessella.com
I have a simple rule flow of the form: Start -> Work Item -> Wait State ->
Action -> End.
The handler for the work item launches a separate thread, and then
completes. This thread inserts a number of facts into the (stateful)
session's working memory; each fact ('SimpleFact') has a boolean property
('complete') that is initially set false. Later on in the thread, the
facts in memory are updated by setting their 'complete' properties to
true.
I want the Wait State to hold execution of the rule flow until ALL the
facts in memory have the 'complete' property set to true. My first attempt
at setting the constraint was as follows:
forall(SimpleFact(complete == true))
With this constraint, the Action node executes straight after the
completion of the Work Item. My next attempt for the constraint was:
exists(SimpleFact()) and forall(SimpleFact(complete == true))
With this constraint, the Action node executes as soon as the first
instance of SimpleFact is inserted into the working memory.
So my question is: how do I specify the Wait State node constraint so that
the rule flow only resumes once all the SimpleFact instances in working
memory have their 'complete' property set to true?
(I have a simple project to demonstrate the problem if required.)
Many thanks,
Alan
14 years, 11 months
Drools and OSGi
by AervTerrh
Hey,
Okay. I know this problem can be found all over. But I can't seem to figure
out a solution to it. Somehow I must be doing something wrong. I've created
a simple application that evaluates some rules and changes some objects
based on that. Everything worked fine, not a single problem there. All
libraries could be easily found etc.
Now I wanted to convert this to a Felix OSGi bundle.
So, what I did, was creating a bundle (new plugin project based on existing
jars) with the drools jars (core, compiler, api, jsr) and tried the next
code in the RuleEngine class:
Properties props = new Properties();
props.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props, null);
(here's where it fails)
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
kbuilder.add(ResourceFactory.newClassPathResource(fileName,
RuleEngine.class), ResourceType.DRL);
This is pretty much the loading of the rule file. The RuleEngine is started
in an Activator. The file is found and everything. But I keep getting the
same error when starting the bundle.
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.mvel.MVELDialectConfigurati on:mvel:null'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(P
ackageBuilderConfiguration.java:274)
at org.drools.compiler.PackageBuilderConfiguration.buildDialect
ConfigurationMap(PackageBuilderConfiguration.java:259)
at org.drools.compiler.PackageBuilderConfiguration.init(Package
BuilderConfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:148)
at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnow
ledgeBuilderConfiguration(KnowledgeBuilderProviderImpl.java: 21)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuild
erConfiguration(KnowledgeBuilderFactory.java:68)
at test.Activator$RuleCreator.createRule(Activator.java:52)
at test.Activator.start(Activator.java:32)
at org.apache.felix.framework.util.SecureAction.startActivator(
SecureAction.java:639)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1 700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622 )
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.j ava:1077)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl .java:264)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.mvel.MVELDialectConfiguratio n
at java.net.URLClassLoader$1.run(Unknown Source)
The packages I import in the manifest:
Import-Package: org.codehaus.janino;version="2.4.3",
org.drools,
org.drools.builder,
org.drools.compiler,
org.drools.io,
org.drools.rule,
org.drools.rule.builder.dialect.java,
org.drools.rule.builder.dialect.mvel,
org.osgi.framework;version="1.3.0"
In my target platform I add the the drools project I created (with
drools-xx.jar (the necessary ones), I also added the following:
-ant
-antlr-runtime
-janino
-jsr94
-xstream
But I can't seem to get it working... Does anyone know what can be done
about this? Or a working example of Drools in Felix OSGi would also be
helpful.
Any help is very much appreciated, I've been looking into this for days.
Thanks!
Kind regards,
Aerv
--
View this message in context: http://n3.nabble.com/Drools-and-OSGi-tp694011p694011.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months