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
14 years, 1 month
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.
14 years, 1 month
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.
14 years, 1 month
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.
14 years, 1 month
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/
14 years, 1 month
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.
14 years, 1 month
Using external classes in BPMN (serviceTask?)
by sam.squire@paretopartners.com
Hello,
I can run Java from within a scriptTask but do not seem to be able to use
external classes properly.
How might I call methods on a class using a serviceTask?
A previous post[1] referred to creating an interface of the class and then
referring to that interface. Is that interface the equivalent of an import
in the native drools XML format?
[1] http://www.mail-archive.com/rules-users@lists.jboss.org/msg15014.html
Has anybody been able to get this to work? Can anyone point me in the
right direction?
Thanks!
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
14 years, 1 month
error importing java built in api's inside functions
by Kripa Nathwani
Hi,
Inside a function I am trying to import java api i.e. java.math.* so that I can use in built math function to perform certain calculations but it does not recognize and validate it.
I also tried to import the rt jar file(through "new file" option in drools 5.1 ) but the package does not get built and gives import error. It seems it is not able to recognize the jar.
Is there any way by which I can use the java api or start importing the api jars into package(I don't want to use it as fact. Hence I am not using "upload pojo model jar" option).
Best Regards,
Kripa
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
14 years, 1 month