forall not delivering as expected
by Wolfgang Laun
Given classes
class Triangle { int a, b, c;... }
class Quadrangle { int a, b, c, d;... }
with appropriate getters (but no hashCode or equals) and these facts
Triangle( 3, 3, 3 )
Triangle( 3, 3, 3 ) // a duplicate, intentional
Quadrangle ( 3, 4, 5, 6 );
the rule
rule "all equilaterals have a 'fitting' quadrangle"
when
forall( Triangle( $a: a, b == $a, c == $a )
Quadrangle( a == $a || b == $a || c == $a || d == $a ) )
then // ...
end
works as expected - it fires.
But the rule
rule "all equilaterals have a duplicate"
when
forall( $t: Triangle( $a: a, b == $a, c == $a )
Triangle( this != $t, a == $a, b == $a , c == $a ) )
then // ...
end
does not fire, not even when I omit this != $t. Why?
Do I have a white spot in my grey cells? Please tint my taint...
-W
14 years, 1 month
Droos Guvnor 5.1.1 - Relation between Category and Package
by Achyutha, Venkata
Hi,
I am using ServiceImplementaion.java class to read categories and packages in repository, I didn't find any method in this class to get like what all packages are there for Category. Can someone please point out me how to get this relation.
We are developing small ui, where we show Category in dropdown, its packages in one more dropdown and rules in one more dropdown. This is little urgent requirement, help would be highly appreciated.
Thanks
Kumar
14 years, 1 month
BuildError: Unable to resolve ObjectType
by BS
Hi all,
I'm quite new to Drools and have a problem with the guided editor of the
Eclipse plugin. I'm using Drools 5.0.1.
These are the two BuildErrors for "TestGuided.brl" in Eclipse:
1) BuildError: Unable to build expression for 'consequence': Failed to
compile: 1 compilation error(s): - (1,1) unqualified type in strict mode
for: p ' update( p );
2) BuildError: Unable to resolve ObjectType 'Produkt'
In "drools.package" I have all necessary imports and also the package
statement. This is the BRL source of "TestGuided.brl":
<rule>
<name>TestGuided</name>
<modelVersion>1.0</modelVersion>
<attributes/>
<metadataList/>
<lhs>
<fact>
<factType>Produkt</factType>
<boundName>p</boundName>
</fact>
</lhs>
<rhs>
<modify>
<fieldValues/>
<variable>p</variable>
</modify>
</rhs>
</rule>
When I use the generated DRL output of the guided editor in a DRL file, I do
not get any error message. The DRL file looks like this and compiles
perfectly in Eclipse:
package com.test
rule "TestGuided"
dialect "mvel"
when
p : Produkt( )
then
update( p );
end
Adding the BRL from above to Guvnor does not throw any error. The BRL
validates and compiles perfectly in Guvnor.
So, why is it only in the guided editor of Eclipse not working but in the
guided editor of Guvnor as well as DRL file? Maybe something in my
configuration is errorneous?
Any help is appreciated, many thanks
Bernd
--
View this message in context: http://n3.nabble.com/BuildError-Unable-to-resolve-ObjectType-tp702633p702...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 1 month
Drools and Java EE
by ljnelson
Hello; I've made a JCA resource adapter for Drools.
I've had to hack quite a bit to get it so that the KnowledgeAgent- and
resource-scanning-related parts don't use Threads, but, instead, use the
JCA-supplied WorkManager and BootstrapContext#createTimer() for asynchronous
operations (like resource scanning and notifying).
Here are some changes it would sure be nice to see, that I needed to hack
around in order to make it so that a KnowledgeAgent-produced KnowledgeBase
could be shared by Java EE components in a specification compliant manner:
1. ResourceChangeNotifierImpl#ProcessChangetSet is an inner class that is
marked as public static, but which has a package-protected constructor. I
have to create a new instance of this in order to create a
ResourceChangeNotifierImpl subclass that doesn't use threads. I hope this
constructor could be made public instead. Right now I'm calling
setAccessible(true). Yecch.
2. ResourceFactory#setFactoryService(): sure do wish this were public, or
that there were another way to install a ResourceFactoryService. I need to
do this so that the scanner and notifier are under my control (and don't use
Threads, but instead use Timers as provided by the JCA BootstrapContext
class). It appears that I do have some control here in Drools 5.1 with the
(undocumented) ServiceRegistry interface (how do I get an instance of it?
what does it do? is it used pervasively?), but I don't know, since it's
undocumented, whether it's the preferred way to do this sort of thing or
not.
3. All this indirection is really quite clunky, especially given the
META-INF/services facility. Was there a good reason this was not used? I'm
sure there was something, because having to consult a factory for a service
to get a provider to produce an instance of something is a bit much.
Hacking around those limitations, I was able to produce a Drools resource
adapter that vends KnowledgeBase instances as its user connection factories.
This means to use it in a spec-compliant manner, you do this in your
stateless (or stateful) session bean:
@Resource
private KnowledgeBase kb;
...and you get injected a wrapper KnowledgeBase that uses the Java EE
container's JCA machinery to invoke operations on the shared KnowledgeBase.
Is this something that would be interesting to other people? If so I am
happy to open source it.
Thanks for a great toolkit.
Best,
Laird
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-and-Java-EE-tp...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 1 month
JBoss Rule Trace feature with 5.0
by Kinjal Khandhar
Hi All,
Can anybody help me with Drools Audit Log(Rule Trace) feature.
My goal is to check which rule got executed,in what sequence and which
conditions got evaluated and which did not.
Any help/pointers greatly appreciated.
Thanks in advance.
Regards,
Kinjal
14 years, 1 month
5.1.1: ArrayIndexOutOfBoundsException in org.drools.core.util.AbstractHashTable
by Lubos
Exception occures at:
org.drools.core.util.AbstractHashTable$HashTableIterator.next(AbstractHashTable.java:317)
in Drools 5.1.1 when calling insert() on just created
StatefulKnowledgeSession.
I found similar issues reported for LeftTupleIndexHashTable, it had to do
with initializing row to -1 instead of 0 or something similar. I see that
fixed in Left/RightTupleIndexHashTable but it seems to me like it is still
present in AbstractHashTable.
The bug occures randomly (inserting the same data), usualy under load. The
index is either -1 or too high. I create multiple sessions in threads from
one KnowledgeBase, sessions are not shared.
Stack trace I got is:
java.lang.ArrayIndexOutOfBoundsException: 16
at
org.drools.core.util.AbstractHashTable$HashTableIterator.next(AbstractHashTable.java:317)
at
org.drools.reteoo.EntryPointNode.updateSink(EntryPointNode.java:323)
at
org.drools.reteoo.ObjectTypeNode.attach(ObjectTypeNode.java:303)
at
org.drools.reteoo.builder.PatternBuilder.attachObjectTypeNode(PatternBuilder.java:257)
at
org.drools.reteoo.ClassObjectTypeConf.<init>(ClassObjectTypeConf.java:92)
at
org.drools.common.ObjectTypeConfigurationRegistry.getObjectTypeConf(ObjectTypeConfigurationRegistry.java:68)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:981)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
I am not sure if this post belongs here, sorry if not.
Thanks for help/suggestions
Lubos
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/5-1-1-ArrayIndexOutOf...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 1 month
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.
||
14 years, 1 month
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, 1 month
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
14 years, 1 month