Some Problem with drools-persistence-jpa Library
by tangrui.cn@gmail.com
Hi list,
The attachment is a very simple test case to demonstrate an application
using Drools Persistence JPA (5.1.1).
Usage:
1. set up a mysql database called framework
2. set the user/password are root/root (or change the
bitronix-datasources.properties file)
3. run maven test
The core lines are as following:
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, conf, env);
ProcessInstance pi = ksession.startProcess("com.zyeeda.system.TestFlow");
pi.signalEvent("signal", "goon");
When executing the 3rd line, an exception occurred
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.zyeeda.test.AppTest.testProcessPersistence(AppTest.java:84)
I've headed into the code and find that some working memory related to the
ProcessInstanceImpl is null.
(drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java)
But I cannot get why this does happen. Please give me some tips.
I tried to google some solutions, but find only this one (
http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Events-No...),
but it seems that he solved this problem by using a custom command.
Thank you!
--
唐睿
14 years
Custom UI for Drools rules
by Balasenthil D
Hi,
Is it possible to create a custom UI to create/edit drools rules( instead of Drools Guvnor). Are there APIs that let you do it?
For e.g., oracle provides a java API for create/edit rules. With this you can come up with your own UI, if you are not happy with jdeveloper.
Is something similar possible with Drools too?
Thank you
Bala
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
14 years
Error with update in Guvnor
by John Peterson
Hi all,
I'm getting a strange error when I run my rules deployed from Guvnor.
Here's the rule:
WHEN
Fact1 [f1]
Flag1 = false
Flag2 = false
Fact2 [f2]
KeyField = f1.KeyField
THEN
f1.Flag2 = true;
update(f1);
f2.count1 = f2.count1 - 1;
f2.count2 = f2.count2 - 1;
f2.count3 = f2.count3 - 1;
f2.count4 = f2.count4 - 1;
f2.count5 = f2.count5 - 1;
update(f2);
I get the following error in my console when I run:
Exception in readKnowledgeBase: [Error: illegal use of operator:
PROJECT]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
If I remove the second update, it runs without error (but my rules
dependent on the updated f2 don't work). I'm doing this in the Guided
Editor. I've tried both "Modify the values of f2" and doing the update
as free form DRL ("update(f2);"). As listed above, if I put a print
between the last assignment and the update, I get the print results
before the error. If I put the print last, I never see it, so I'm 99.9%
certain it is choking on my update.
Version Specifics:
- Guvnor 5.0.1
- Drools 5.0.1
- JBoss 4.2.3.GA
Any help/guidance would be appreciated!
14 years
Guvnor : Globals and variables in test scenario
by Stela Dabija
Using : Guvnor 5.2 (in development)
Tomcat 6.0.28
Java 1.6.0_20
Looks like there is an issue when creating a TestScenario which:
1. Has some fact field set to a variable
2. And, Has some global variable
Steps:
1. In the package configuration define a global variable : "global
Object glVar"
2. Create new Declarative model (see attached image S1_model):
a. FactType : name ="FType1"
b. FactType : name = "FType2"
i.
Field : name="ch"/type="FType1"
c. FactyType : name = "FType3"
i.
Field : name="ch"/type="FType2"
3. Create new TestScenario (see attached images
S2_TestScenario_before and S3_TestScenario_after):
a. Insert a new fact : type="FType2", varName = "f2"
b. Insert a new fact : type = "FType3", varName="f3"
i.
Add a field : name="ch", value = "=f2" (bound to variable f2)
c. Add new Global (glVar).
Observed: after adding the global variable nothing in the TestScenario
screen is displayed.
It is not possible to make any changes to the TestScenario content (for
ex delete the global var).
After saving the TestScenario it is no longer possible to open it.
Do you know if there is any workaround? Is there an open issue for this?
Thank you,
Stela
14 years
How to count distinct?
by Yaniv Itzhaki
Hi All,
I need to go over a not distinct list and count distinct each element in the
list.
for example:
Object XXX {
int id;
String type;
}
XXX:
id type
1 A
2 B
3 A
4 C
5 C
The rule should be activated per type and give as a result the count of each
type:
A 2
B 1
C 2
Thanks
14 years
Temporal operator before[1ms, oo] exhibtis strange behaviour
by Wolfgang Laun
The .drl:
declare Leave
@role( event )
@timestamp( timestamp )
end
rule "XXX Leave not !="
when
$leave: Leave()
not Leave( this != $leave )
then
System.out.println( "XXX only one Leave - not !=" );
end
rule "YYY Leave not after"
when
$leave: Leave()
not Leave( this before $leave )
then
System.out.println( "YYY only one Leave - not before" );
end
A) The pseudo-clock is advanced according to the timestamp; then
exactly one event Leave is inserted; then fireAllRules() is called.
1) Running in CLOUD mode, both rules fire.
2) But running in STREAM mode, ONLY rule XXX fires.
B) Like A, but the session clock is advanced by (at least) 1ms
prior to calling fireAllRules().
3) Either mode, both rules fire.
I think that A2) is incorrect; why should passing another msec change the
logic?
JIRA?
Wolfgang
14 years
The Field rulesByteArray in Table SessionInfo Always Empty
by Rui Tang
Hi list,
I have a very simple webapp demo based on drools-persistence-jpa.
I can obtain a StatefulKnowledgeSession from this statement:
ksession = JPAKnowledgeService.newStatefulKnowledgeSession(this.kbase,
null, env);
and the SessionInfo will be stored into database correctly, except that the
rulesByteArray field is always empty.
Then I use the following statement to retrieve this ksession, but NPE
occurred.
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(
command.getSessionId(), this.kbase, null, env);
I've read the code (JPASessionMarshallingHelper.loadSnapshot()) and find
that this should be caused by the empty rulesByteArray filed.
I'm wondering in which case this field is empty, and how to make it work
correct.
Below is the stacktrace:
Caused by: java.lang.IllegalStateException:
java.lang.reflect.InvocationTargetException
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:110)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.loadStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:78)
at
org.drools.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(JPAKnowledgeService.java:118)
at
com.zyeeda.framework.knowledge.internal.DroolsKnowledgeServiceProvider.execute(DroolsKnowledgeServiceProvider.java:165)
at
$KnowledgeService_12c173f2df7.execute($KnowledgeService_12c173f2df7.java)
at
com.zyeeda.framework.resources.SampleFlowResource.start(SampleFlowResource.java:36)
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.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
... 49 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:95)
... 60 more
Caused by: java.lang.NullPointerException
at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
at
org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:85)
at
org.drools.persistence.session.SingleSessionCommandService.initKsession(SingleSessionCommandService.java:196)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:159)
Thank you very much!
--
唐睿
14 years
case in-sensitive string comparison?
by H.C.
We have a requirement to display data as stored (with the right casing) but
for evaluation purposes strings should be compared case in-sensitive. We
have several hundred rules touching these particular strings and would
really like to avoid doing eval( x != null && x.equalsIngoreCase(y) )
everywhere. Is there anywhere in drools that we could configure to make
string matching case in-sensitive?
Since we have to display the data with casing elsewhere, putting
x.toLowerCase() in all our getter methods doesn't seem to be an option.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/case-in-sensitive-str...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years
Marshalling Error : JBRULES-2453
by drooRam
JBRULES-2453, This issue has been closed stating that it got fixed in 5.1.0
CR1. But I got the same issue in 5.1.1, following is the stacktrace of
error:
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into SessionInfo (lastModificationDate, rulesByteArray,
startDate, OPTLOCK, id) values (?, ?, ?, ?, ?)
Hibernate: select hibernate_sequence.nextval from dual
java.lang.RuntimeException: Could not commit session
at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:292)
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:193)
at
edu.rascalworkflow.test.LoanRequestTest.startProcess(LoanRequestTest.java:58)
at
edu.rascalworkflow.test.LoanRequestTest.testRequestLoan(LoanRequestTest.java:48)
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.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.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
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)
Caused by: org.springframework.transaction.TransactionSystemException: Could
not commit JPA transaction; nested exception is
javax.persistence.RollbackException: Error while committing the transaction
at
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:476)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at
org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.commit(DroolsSpringTransactionManager.java:65)
at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:281)
... 31 more
Caused by: javax.persistence.RollbackException: Error while committing the
transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:93)
at
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:467)
... 35 more
Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap
space
at org.hibernate.ejb.event.BeanCallback.invoke(BeanCallback.java:45)
at
org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:94)
at
org.hibernate.ejb.event.EntityCallbackHandler.preUpdate(EntityCallbackHandler.java:79)
at
org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:61)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:349)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:287)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
... 36 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at
java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847)
at
java.io.ObjectOutputStream$BlockDataOutputStream.write(ObjectOutputStream.java:1778)
at java.io.DataOutputStream.writeInt(DataOutputStream.java:182)
at
java.io.ObjectOutputStream$BlockDataOutputStream.writeInt(ObjectOutputStream.java:1913)
at java.io.ObjectOutputStream.writeInt(ObjectOutputStream.java:777)
at
org.drools.marshalling.impl.OutputMarshaller.writeLeftTuple(OutputMarshaller.java:482)
at
org.drools.marshalling.impl.OutputMarshaller.writeLeftTuple(OutputMarshaller.java:466)
at
org.drools.marshalling.impl.OutputMarshaller.writeInitialFactHandleLeftTuples(OutputMarshaller.java:379)
at
org.drools.marshalling.impl.OutputMarshaller.writeFactHandles(OutputMarshaller.java:274)
at
org.drools.marshalling.impl.OutputMarshaller.writeSession(OutputMarshaller.java:102)
at
org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:133)
at
org.drools.persistence.session.JPASessionMarshallingHelper.getSnapshot(JPASessionMarshallingHelper.java:72)
at org.drools.persistence.session.SessionInfo.update(SessionInfo.java:75)
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.hibernate.ejb.event.BeanCallback.invoke(BeanCallback.java:37)
at
org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:94)
at
org.hibernate.ejb.event.EntityCallbackHandler.preUpdate(EntityCallbackHandler.java:79)
at
org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:61)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:349)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:287)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
-drooRam.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Marshalling-Error-JBR...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years