Problem in getting session from JPAKnowledgeService.newStatefulKnowledgeSession();
by Bennet Joseph
Hi All,
follwoing is the code i used to get the session using
JPAKnowledgeService.newStatefulKnowledgeSession.
table for the mentioned classes are getting created, after that
JPAKnowledgeService.newStatefulKnowledgeSession() method throws following
exception....
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
env.set( EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager() );
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
-------------------------
persistence.xml
i copied only persistent unit part...
<persistence-unit name="org.drools.persistence.jpa">
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
<property name="hibernate.connection.url"
value="jdbc:oracle:thin:@192.168.4.93:1521:POST" />
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.password" value="voms_test"
/>
<property name="hibernate.connection.username" value="voms_test"
/>
<property name="java.naming.factory.initial"
value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
<!--
<property name="hibernate.format_sql" value="true"/>
-->
</properties>
</persistence-unit>
but it throws exception
java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:137)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:61)
* at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at com.sample.FirstTest.main(FirstTest.java:87)*
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:123)
... 3 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:132)
... 8 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at
org.drools.persistence.session.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:130)
... 8 more
Caused by: java.lang.NullPointerException
at
org.drools.persistence.session.JtaTransactionManager.rollback(JtaTransactionManager.java:178)
... 9 more
14 years
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
How to store Session or session info.
by Bennet Joseph
Hi All,
i am trying to execute the flow, and it is persisting history log in
ProcessInstanceLog and NodeInstanceLog.
if the server crashes, from where i have to retrive the session details.
Thanks,
Jose.
14 years
Start TaskServer in Execution Server
by raic
Hi,
There is a way for starting the MinaTaskServer at ExecutionServer startup? I
want to configure TaskServer out of the application and to have it always
"up".
I mean to replace this code from the application to some configuration in
execution server:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.task");
TaskService taskService = new TaskService(emf,
SystemEventListenerFactory.getSystemEventListener());
TaskServiceSession taskSession = taskService.createSession();
taskSession.addUser(new User("Administrator"));
taskSession.addUser(new User("foo"));
taskSession.addUser(new User("foo1"));
MinaTaskServer server = new MinaTaskServer(taskService);
Thread thread = new Thread(server);
thread.start();
Any idea will be appreciated
Thanks!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Start-TaskServer-in-E...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years
Re: [rules-users] rules-users Digest, Vol 48, Issue 89
by Shivram kalwar
Hello All ,
I have 2 question on drools 5.1 ,I am using the Tomcat server,
1)where can i see the drools file(.drl) converted into .java file, I mean
internally drools convert the .drl into .java and uses the .java at runtime
?
2) suppose in drools when condition it has many statements so how the logic
works for then condition ..
i Have statement in when for some object the working memory got modified for
some it is not and there are many conditional statements(true or flase) are
there on multiple Object(like Parts ,Discount, etc)
Thank you very much for you guideline in advance.
shiv
14 years
5.2.0-SNAPSHOT java.io.OptionalDataException
by mjhn
Hi,
I'm using the 5.2.0-SNAPSHOT binaries for making use of the new auth
attributes in the kagent:resource tag.
I'm attempting to get PKG out of Guvnor. Using the following
droolsservice.xml config
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://drools.org/schema/drools-spring
http://192.168.2.2/~martinjohnson/xmpp_code/drools-spring-1.2.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd" >
<drools:kagent kbase="knowledgeBase" id="kagent" new-instance="false">
<drools:resources>
<drools:resource type="CHANGE_SET"
basic-authentication="enabled" username="admin" password=""
source="http://localhost:8080/drools-guvnor.war/org.drools.guvnor.Guvnor/package/..."
/>
</drools:resources>
</drools:kagent>
</beans>
As far as i can tell the ChangeSet.xml is coming down. The PKG accessed.
Though then...
Nov 25, 2010 9:09:52 PM com.javawhat.rules.RuleAgentManager init
INFO: Loading knowledge agents ...
Nov 25, 2010 9:09:52 PM com.javawhat.rules.RuleAgentManager init
INFO: Initializing knowledge agents with package:
[2010:11:329 21:11:675:info] ResourceChangeScanner reconfigured with
interval=60
[2010:11:329 21:11:676:info] ResourceChangeScanner created with default
interval=60
[2010:11:329 21:11:682:info] ResourceChangeScanner reconfigured with
interval=120
[2010:11:329 21:11:682:info] ResourceChangeScanner reconfigured with
interval=120
[2010:11:329 21:11:14:info] ResourceChangeNotification created
[2010:11:329 21:11:14:debug] ResourceChangeNotification monitor added
monitor=org.drools.io.impl.ResourceChangeScannerImpl@37722456
[2010:11:329 21:11:17:debug] KnowledgeAgent building resource map
[2010:11:329 21:11:17:info] KnowledegAgent has started listening for
ChangeSet notifications
[2010:11:329 21:11:18:info] KnowledgeAgent created, with configuration:
monitorChangeSetEvents=true scanResources=true scanDirectories=true
newInstance=false
[2010:11:329 21:11:514:info] KnowledgeAgent applying ChangeSet
[2010:11:329 21:11:516:debug] KnowledgeAgent notifier subscribing to
resource=[UrlResource
path='http://localhost:8080/drools-guvnor.war/org.drools.guvnor.Guvnor/package/...']
[2010:11:329 21:11:516:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@23000bcf to
resource=[UrlResource
path='http://localhost:8080/drools-guvnor.war/org.drools.guvnor.Guvnor/package/...']
[2010:11:329 21:11:516:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@580754fc to
resource=[UrlResource
path='http://localhost:8080/drools-guvnor.war/org.drools.guvnor.Guvnor/package/...']
[2010:11:329 21:11:517:debug] KnowledgeAgent rebuilding KnowledgeBase using
ChangeSet
[2010:11:329 21:11:517:info] KnowledgeAgent performing an incremental build
of the ChangeSet
[2010:11:329 21:11:280:exception]
java.lang.RuntimeException: KnowledgeAgent exception while trying to
deserialize KnowledgeDefinitionsPackage
at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:665)
at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:618)
at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:809)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:587)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:186)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:169)
at
com.javawhat.rules.RuleAgentManager.createKnowledgeAgent(RuleAgentManager.java:125)
at com.javawhat.rules.RuleAgentManager.init(RuleAgentManager.java:85)
at
com.javawhat.rules.RuleAgentManager.getInstance(RuleAgentManager.java:48)
at com.adstream.test.Main.main(Main.java:53)
Caused by: java.io.OptionalDataException
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1282)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at
org.drools.rule.JavaDialectRuntimeData.readExternal(JavaDialectRuntimeData.java:167)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at java.util.HashMap.readObject(HashMap.java:1030)
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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at
org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:59)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.drools.rule.Package.readExternal(Package.java:197)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at
org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:205)
at
org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:174)
at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:654)
... 9 more
[2010:11:329 21:11:283:warning] KnowledgeAgent: The resource didn't create
any package: [UrlResource
path='http://localhost:8080/drools-guvnor.war/org.drools.guvnor.Guvnor/package/...']
[2010:11:329 21:11:283:info] KnowledgeAgent incremental build of
KnowledgeBase finished and in use
[2010:11:329 21:11:284:debug] KnowledgeAgent finished rebuilding
KnowledgeBase using ChangeSet
The issue lies behind 'stream.readObject();' from JavaDialectRuntimeData
around line 167
// Return the object stored as a byte[]
byte[] bytes = (byte[]) stream.readObject();
if ( signed ) {
checkSignature( stream,
helper,
bytes,
pubKeyAlias );
}
guvnor and my sample app are both running 5.2.0-SNAPSHOT. Really appreciate
any advice. Is it falling over an a parse of the binary and some
disagreement on contents of payload?
Thanks
Martin
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/5-2-0-SNAPSHOT-java-i...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years
Temporal constraint not causing rule activation when using StatefulKnowledgeSession.update()
by Nathan Bell
To demonstrate the issue I have simplified the following sample rule to
just the components needed to demonstrate the issue. The example rule
I'm posting here uses the "after" operator; I have also tried this same
test with the before operator. In this sample the rule named "AfterRule"
will activate if the facts are initially inserted in a state matching
the pattern. However, if the facts are inserted in a state that does not
match, and then later updated to match the pattern using
StatefulKnowledgeSession.update() the rule will not activate.
Consider the following DRL:
package test.rules;
dialect "java"
import java.util.Date;
import com.p1s.mps.model.RuleTime;
import com.p1s.mps.model.Patient;
declare RuleTime
@role( event )
@timestamp( time )
end
declare Patient
@role( event )
@timestamp( birthDate )
end
rule "AfterRule"
when
$now : RuleTime( )
Patient( this after $now )
then
System.out.println("after");
end
Separately in a unit test the following actions are performed:
1. Insert an instance of RuleTime into the session where time is
set to now.
2. Insert an instance of a patient into the session where the
birthdate is set to (now - 1 day). [This makes the birthdate in the past
so the rule does not activate]
3. Call fireAllRules(). The rule does not activate, as expected.
4. Modify the patient instance to have a birthdate set to (now + 1
day).
5. Invoke update() on knowledge session.
6. Call fireAllRules(). The rules does not activate. It should
activate here.
If I change step 5 to a retract + insert then the rule will activate in
step 6 as expected.
Thank You,
Nathan Bell
14 years
Rules trace questions
by Anais Martinez
Hello.
I'm trying to get the rules trace in execution by using
WorkingMemoryFileLogger. I am using the Hello word example, and I call the
WorkingMemoryFileLogger.wirteToDisk() in the RHS of rules. My modified drl
file is:
import com.sample.DroolsTest.Message;
global org.drools.audit.WorkingMemoryFileLogger rulesLogger
declare Output
@role (event)
end
rule "Hello World"
when
m : Message( status == Message.HELLO, myMessage : message )
then
System.out.println( myMessage + ": Hello message" );
m.setMessage( myMessage );
m.setStatus( Message.GOODBYE );
update( m );
end
rule "GoodBye"
when
Message( status == Message.GOODBYE, myMessage : message )
then
System.out.println( myMessage + ": Goodbye message" );
Output o= new Output();
insert(s);
end
rule "log trace"
when
o:Output( )
then
System.out.println("Loggin trace");
rulesLogger.writeToDisk();
end
I have filtered the logger to see only LogEvent.ACTIVATION_CREATED, and I
set the global rulesLogger in Main(). If I insert 2 messages, 2 "event.log"
files and one "test.log" appears. I have several questions (sorry if I say
nonsense):
First. How do I read the trace for each fire of "rule to log trace"? I mean,
the trace for "rule to log trace" is written forward (from event
insertion/updating/removing to "log trace" activation) or backward (from
"log trace" activation to event insertion/updating/removing)?
Second. Each event.log appears in each "log trace" activation because I am
writing the trace in the RHS. Am I right? Can I use that in order to read
the trace for each individual activation of "log trace"?
Third. I only allow LogEvent.ACTIVATION_CREATED, but some ObjectLogEvent
appear in the test.log file, but not in the event.log files. Why?
Thanks in advance.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-trace-questions...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years