Matching strings in two arrays
by Kumar Pandey
Drools 5.1.0
I have a need to match list of incoming strings to those in the rule. All
the strings in the fact object needs to exists in the rule.
I have a large set of rules around 5000.
In general I have around 4 conditions per rule and its taking in average
around 30- ~40 ms to go through the 5000 rules.
However the following construct that I am using to match the incoming set of
input strings is adding on the average 200ms to rules execution.
Is there a more efficient way to do this?
MyContext is the fact class and classes is array of String.
I need to make sure that the classes array contains all three
strings TestString1, TestString2 and TestString3.
MyContext(DclassesList : classes)
exists( String(this matches "TestString1") || String(this matches
"TestString2") || String(this matches "TestString3") from DclassesList)
Of course each rule in the 5000 can have diff set of strings to match.
Thanks
15 years, 7 months
Error in named query: ProcessInstancesWaitingForEvent
by Eugenio Abello
Hi, I'm using drools 5.1.1 with persistent flow and Human Task. In orm.xml
are queries Flow and HT. But among this error initializing JPA:
ERROR 24-09 17:20:36,375 - Error in named query:
ProcessInstancesWaitingForEvent
org.hibernate.QueryException: cannot dereference scalar collection element:
name [select processInstanceInfo.processInstanceId from
org.drools.persistence.processinstance.ProcessInstanceInfo
processInstanceInfo where :type in
(processInstanceInfo.eventTypes.name<http://processinstanceinfo.eventtypes.name/>
)]
thanks
15 years, 7 months
Drools with Spring Batch
by Manav
Hi,
I am trying to integrate Drools with Spring Batch. Is there some documentation
that could throw some light on the configuration involved in the same.
Regards,
Manav
15 years, 7 months
Using CGLIB BeanGenerator as fact object
by Kumar Pandey
I'm exploring the possibility of using a dynamic bean as fact object as my
fact object is very dynamic in nature.
I came across posts where people had recommended using BeanGenerator from
CGLIB.
This blog does a very good job of explaining the details of classloader
etc.
http://blog.athico.com/2006/12/dynamically-generated-class-beans-as.html
>From what I can gather ( I'm new to both CGLIB and drools ) CGLIB seems to
have the lowest lerning curve to achieve this.
I have the below sample on creating a dynamic bean with CGLIB
BeanGenerator bg = new BeanGenerator();
bg.setSuperclass(FactContextPlaceHolder.class);
bg.setNamingPolicy(new net.sf.cglib.core.NamingPolicy() {
public String getClassName(String prefix, String source, Object key,
Predicate names) {
return prefix + "Impl";
}
});
bg.addProperty("foo", Double.TYPE);
g.addProperty("bar", String.class);
FactContextPlaceHolder beanInst = (FactContextPlaceHolder)bg.create();
Here com.drools.test.FactContextPlaceHolder is set as super class and the
generated class is obtained as com.drools.test.FactContextPlaceHolderImpl
I have two basic question I am unable to find some answers on.
1) Once I create an object, how do I actually set the state of this object
with fact values before setting it as fact object to drools session?
In the above example how do I set value of foo to "foot-test1" and value of
bar to "bar-test1" on the beanInst.
2) In DRL if I set the package to some path say com.drools.test
Should I then use FactContextPlaceHolderImpl as my fact Object?
Thanks
Kumar
15 years, 7 months
Drools Flow Events Not Working
by jawa
Hi,
I am using drools flow 5.1.1 with JPA. I want my flow to stop at a certain
point so I use an AND node with one incoming RuleGroup node and one incoming
Event node. so as AND guarantees that It executes after both of the nodes
are completed. So my flow stops there. Then i load the session from db and
use following to raise an event on the session:
StatefulKnowledgeSession session =
JPAKnowledgeService.loadStatefulKnowledgeSession(9,knowledgeBase, null,
environment);
ProcessInstance p = session.getProcessInstance(9);
System.out.println("Proc Found -> " + p);
if (p != null && p.getState()==ProcessInstance.STATE_ACTIVE)
{
p.signalEvent("Test", vo);
}
But it fails with following exception:
Exception in thread "main" java.lang.NullPointerException
at
org.drools.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:185)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:346)
at com.my.poc.PocFlowServiceImpl.processFlow(PocFlowServiceImpl.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
at
org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
at
org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
at
org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
at
org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_20004366.invoke(InvocationContextInterceptor_z_fillMethod_20004366.java)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
at
org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_20004366.invoke(InvocationContextInterceptor_z_setup_20004366.java)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.tx.StatelessBMTInterceptor.handleInvocation(StatelessBMTInterceptor.java:106)
at org.jboss.ejb3.tx.BMTInterceptor.invoke(BMTInterceptor.java:55)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)
at
org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)
at
org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)
at
org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)
at
org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)
at
org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:211)
at org.jboss.remoting.Client.invoke(Client.java:1724)
at org.jboss.remoting.Client.invoke(Client.java:629)
at
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy3.invoke(Unknown Source)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
at $Proxy2.processFlow(Unknown Source)
at net.plus.kbd.poc.StartFlow.main(StartFlow.java:39)
at
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy3.invoke(Unknown Source)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
at $Proxy2.processFlow(Unknown Source)
at com.my.poc.StartFlow.main(StartFlow.java:39)
Then i tried to use this code:
SignalEventCommand command = new SignalEventCommand();
command.setProcessInstanceId(9);
command.setEventType("Test");
command.setEvent(true);
session.execute(command);
But it fails:
Exception in thread "main" java.lang.NoSuchMethodError:
org.drools.runtime.StatefulKnowledgeSession.execute(Lorg/drools/command/Command;)Lorg/drools/runtime/ExecutionResults;
at com.my.poc.PocFlowServiceImpl.processFlow(PocFlowServiceImpl.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
Although I have drools jars in my classpath. All required jars including
drools-core-5.1.1.jar
Any idea how can i raise an event ??
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Events-No...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Drools Flow process question...
by bob.breitling
I have a very simple process with one RuleFlow Group.
I am registering an object via the variables.
I have several rules which I am trying to get to fire.
I have rules which constraints on the object I registered that are not
working. I have rules with constraints on the WorkflowProcess I insert that
are not working unless I include another rule with no constraints. When I
debug the Drools code, and I include the rule without constraints, I see the
default agenda-group returning. Without the rule, the agenda-group is
always null. Therefore none of my rules fire. I have yet to get a rule
with constraints based on variables registered in my process to work. I am
basically following the examples from my Drools book.
I am using 5.1.1 jars.
Any help would be greatly appreciated.
TIA,
Bob
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-process-q...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Drools flow variables don't get passed to sub process?
by jawa
Hi,
I've a drools flow which has sub flow node in it. I've create a drools flow
variable both in main flow and sub flow with the same name. Then I use that
variable to set Parameter Mappings of a work item with in my main flow and
in sub flow. The work items in main flow get it fine and works perfectly but
the sub flow work items complain that it couldn't fine parameter. Here is
what i get in logs:
16:43:59,379 ERROR [STDERR] Could not find variable scope for variable
myvo.comment
16:43:59,380 ERROR [STDERR] when trying to execute Work Item My Workitem
16:43:59,380 ERROR [STDERR] Continuing without setting parameter.
In my code i start main flow with a map of parameter called "myvo" and I
assumed that the same variable will be passed to sub flow automatically but
it didn't. Does anyone know how can i pass the parameter to my sub flow ?
Thank you
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-flow-variables...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Few inquiries about Drools
by Nirmal Fernando
Hi,
We are thinking of using Drools rules engine, for our application. But we
have few questions, that we would really happy to get explanations about.
1) Is the latest version Drools 5.1 supports backward chaining? If so since
which release you started to support backward chaining?
2) Are you using "Crisp Logic"? (we can only insert "facts" that are
true/false)
3) Whether Drools allow to intermingle the RuleBase and the WorkingMemory?
Hope to hear from you!
Thanks.
--
Best Regards,
Nirmal
C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.
Blog: http://nirmalfdo.blogspot.com/
15 years, 7 months
import data model to eclipse
by fionali
Hi all,
I am new to drools. and now I have created a data model jar file and want to
import to eclipse. I had added the jar at build path(by configuring build
path, import the library), and added the imports to drools.package. the
issue is that I still can not create guided rule for it can not get fact
from the model (at the guided editor, click WHEN, no fact is avaliable to be
selected).
I suffered a lof from it and had searched the forum,no answer found.
Could anyboy kinderly help me? Thanks a lot!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/import-data-model-to-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months