Loading StatefulKnowledgeSession and Session-ID-Concept
by O.S.
Hi,
I have a question concerning the id-concept of StatefullKnowledgeSessions:
int sessionId = ksession.getId();
While looking up the KnowledgeStoreService-Interface I was a little bit
confused about the loadStatefulKnowledgeSession(...) Method:
|*loadStatefulKnowledgeSession*(int id, KnowledgeBase kbase,
KnowledgeSessionConfiguration configuration, Environment environment)|
I think the first parameter is the session id (see above). But why does
he needs the kbase, config and environment too? Is the session id not
global? Is she bound to one or more of the Classes/Instances
(|kbase|,|configuration,||environment)|?
||
|If the id| is bound, it will implicitly mean that there can be more
than one ksessions with the same id?
Kind regards,
O.S.
||
15 years, 6 months
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.
15 years, 6 months
Drools 5.1 Flow in a "Clustered" environment
by Ken Young
We are looking at embedding Drools 5.1 (specifically Drools Flow) in our application, but I am coming up short on determining how to configure clustering, or the support.
Specifically, I want to ensure that background processes that are taking place (reminders, timers, etc.) only happen once on a cluster. Does drools support this and how?
In other software that we have clustered (Quartz for example), where a shared database lock is used to ensure the the processing happens in one place. I was wondering if Drools 5.1 worked in a similar fashion.
Thanks
Ken
15 years, 6 months
Question about Rete Tree example with NotNode in "Drools JBoss Rules 5.0 Developers Guide"
by Tina Vießmann
Hi,
I'm working through the explanations about Rete Trees in chapter 12 of
"Drools JBoss Rules 5.0 Developers Guide" on page 264-265. I have a
problem in understanding the input of the NotNode.
The rule says:
when
$address : Address ( addressLine == "Rossa Avenue" )
not (
$account : Account ( balance < 100 ) and
Customer ( accounts contains $account )
)
then
...
The related figure shows:
1. The Address object being processed and a tuple will be created by a
LeftInputAdapterNode.
2. The tuple of 1. will be joined with the Account fact with no
constraints (so that there's a tuple of size two?).
3. The tuple of 2. will be joined with the Customer fact with the
restriction 'accounts contains $account'. (That results in a tuple with
size 3!?)
4. The tuple of 3. will then be processed by a RightInputAdapterNode.
5. The tuple/fact from 3. will be processed using a NotNode together
with the Address-tuple from 1.
I don't understand while the tuple from 1. will in step 2 be joined with
the Account fact. I would have expected something like:
1. // same
2. The Account fact will be processed and a tuple will be created by a
LeftInputAdapterNode.
3. The Customer fact will be joined with the Account tuple with the
constraint 'accounts contains $address'. Resulting in a tuple.
4. // somehow the tuple from step 3 will be negated and joined with the
tuple from step 1.
Could anybody explain to me why it's done the way its drawn in the book?
Thank you! :)
Tina
15 years, 6 months
What's wrong with this rule
by 赵侃侃
Hello,
With the help from the community I managed to get my first rule working, and
I'm trying to write my second rule on my own but it just doesn't seem to
work correctly.
Here is the scenario, what I want is to identify a pattern that there's no
EventB coming in within 2 minutes with a particular index value.
For example, EventB would have a property named index and assume the value
of index would be either 0 or 1.
Before firing the rules, I would manually insert facts of possibleIndex with
value 0 and 1 into the workingMemory.
Within 2 minutes, if there only comes one EventB with index valued 0 then
the system should report no EventB coming in with index value 1 in last 2
minutes.
Vice versa, in the case of only coming one EventB with index valued 1 then
the system should report no EventB coming in with index value 0 in last 2
minutes.
If within 2 minutes, there comes 2 EventB with both value 0 and 1 then
nothing should report.
Here is what I wrote, but it doesn't seem to work correctly.
I used a timer to fire this rule every 10 seconds because I don't think the
rule would run automatically if I don't add that. (not too sure though)
rule "no B in 2 minutes"
timer (0 10s)
when
possibleIndex( $index : index ) from entry-point "Event stream"
$p : PatternConsumer ( name == 'no B' && index == $index )
not ( EventB( index == $index && this after[0ms,2m] $p) over window:time(2m)
from entry-point "Event stream" )
then
PatternConsumer pc = new PatternConsumer( "no B", $index );
insert(pc);
System.out.println("no B in 2 minutes " + $index);
end
Best Regards,
Kevin Zhao
15 years, 6 months
Drools Flow in EJBs
by tizo
Hi there,
I have seen in chapter 6 of the documentation, that Drools Flow can be
configured to use JPA and transactions to persist the running states.
However, I am in a EJB where I obtain entity managers with a
@PersistenceContext annotation, and the transactions are managed by the
container, whereas in the example an EntityManagerFactory and a
TransactionManager are used.
Could I configure Flow in a direct way to be used by my EJB?
Thanks very much,
tizo
15 years, 6 months
Replacing Hand Written Rules
by Nirmal Fernando
Hi,
I am having a 5000+ hand written rules which is used in an open source
project.
I am searching for the reasons, me to be shifted to a rule engine like
Drools, instead of using hand written once.
Drools rules can be debugged that will be a plus point, isn't it? I would
love to get a list of benefits that I will be getting.
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, 6 months
OSGi: Unable to Import Packages from Core Bundle
by O.S.
Hi,
i have some troubles while trying to use some classes (e.g.: Commands) from
the org.drools.core Bundle. I can't import packages or set the core bundle
as required:
Import-Package:
org.drools.command.runtime;version="5.1.1",
...
Error in Manifest.MF: Bundle 'org.drools.core' exporting package
'org.drools.command.runtime' is unresolved
But the Bundle can't be unresolved because it is startet correctly. At
Bundle Validation he has an "Uses Package Conflict" concerning:
com.sun.tools.xjc.
Can someone help me or give me a tip?
Kind regards,
O.S.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/OSGi-Unable-to-Import...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 6 months
Creating a KnowledgeBase using a KnowledgeAgent, KnowledgeAgentConfiguration and KnowledgeBaseConfiguration
by Tina Vießmann
Hi,
I want to create a KnowledgeBase using stream processing mode, getting
its resources from an change-set xml and getting the updated when
resources are changed. So far I'm aware I need a KnowledgeAgent and a
configuration for the kagent and the kbase.
My code is:
// create knowledge base
// knowledge base configuration
KnowledgeBaseConfiguration kbaseConf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbaseConf.setOption(EventProcessingOption.STREAM);
// knowledge base
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConf);
// create knowledge agent
// create knowledge agent configuration
KnowledgeAgentConfiguration kagentConf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
//enable incremental knowledge base build
kagentConf.setProperty("drools.agent.newInstance", "false");
//create knowledge agent
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("AITS CEP Engine Agent",
kbase, kagentConf);
// apply change-set XML to knowledge agent
kagent.applyChangeSet(ResourceFactory.newClassPathResource("changeset.xml"));
// get updated knowledge base object
kbase = kagent.getKnowledgeBase();
// create session
session = kbase.newStatefulKnowledgeSession();
Can it be done in a more compact way?
Thank you! :)
Tina
15 years, 6 months
Drools Bug: Custom Operator with Maps results in Mvel Error
by Uday Kodukula
Hello,
I'm not sure if this is a bug, but I'd like to check with the Drools experts
to see if it is.
I noticed this when creating my custom operator, which doesn't appear to
recognize values from Maps, but works fine with non Map based values.
I have created a custom comparison operator which takes in a parameter to
determine how to execute the comparison logic.
So for example, I am able to do the following:
id udaycompare[gt] 1
where id is an integer. So for the sake of clarity this is equivalent to "id
> 1".
Now, when I try to extract an integer from a HashMap called myMap, who has
an integer value for the key "someKey", I get an error raised by MVEL:
myMap["someKey"] udaycompare[gt] 1
Error thrown:
Unable to determine the used declarations.
[Error: unknown class or illegal statement: org.mvel2.ParserContext@1d87b85]
[Near : {... myMap["someKey"] udaycompare ....}]
^
It appears that Mvel doesn't like getting values from HashMap when working
with custom operators. I also tried an alternate way of getting that key
from the map as follows:
myMap.someKey udaycompare[gt] 1
but i still get the same error.
Any thoughts would be greatly appreciated.
Thanks,
Uday
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Bug-Custom-Ope...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 6 months