Drools Persistence Problem
by dmiller44
I'm having a lot of trouble getting the default Drools persistence stuff
working as it's documented in the Drools Flow manual. Below I've included
the stack trace, my dependencies (only those related to drools persistence),
my code snipped (which gets compiled into a jar and used by a war) and the
persistence.xml file (which is also compiled into the jar under
META-INF/persistence.xml). Any help would be appreciated.
*Note: I tried posting this yesterday, but it doesnt seem to have made it
to the mailing list, so sorry for a double post if it did *
Stack trace:
2010-01-07
15:36:26,599|org.springframework.web.context.ContextLoader|main|ERROR||
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'droolsEngineFactory' defined in ServletContext resource
[/WEB-INF/spring/summit/summit-specific.xml]: Invocation of init method
failed; nested exception is java.lang.RuntimeException: Could not commit
session
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.RuntimeException: Could not commit session
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
at
com.versatile.mte.drools.engine.DroolsEngineFactory.init(DroolsEngineFactory.java:189)
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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 39 more
Caused by: javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:109)
... 49 more
2010-01-07
15:36:26,607|org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mte-web-portal]|main|ERROR||
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'droolsEngineFactory' defined in ServletContext resource
[/WEB-INF/spring/summit/summit-specific.xml]: Invocation of init method
failed; nested exception is java.lang.RuntimeException: Could not commit
session
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.RuntimeException: Could not commit session
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
at
com.versatile.mte.drools.engine.DroolsEngineFactory.init(DroolsEngineFactory.java:189)
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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 39 more
Caused by: javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:109)
... 49 more
Dependencies:
<file name="hibernate-3.3.1.ga.jar"/>
<file name="hibernate-annotations-3.4.0.ga.jar"/>
<file name="hibernate-commons-annotations-3.4.0.ga.jar"/>
<file name="hibernate-entitymanager-3.4.0.ga.jar"/>
<file name="javassist-3.4.ga.jar"/>
<file name="jta-1.1.jar"/>
<file name="dom4j-1.6.1.jar"/>
<file name="slf4j-jdk14-1.5.2.jar" />
<file name="btm-1.3.2.jar" />
<file name="h2-1.0.77.jar" />
<file name="postgresql-8.1-407.jdbc3.jar"/>
<file name="drools-persistence-jpa-5.1.0.M1.jar" />
<file name="commons-dbcp-1.2.2.jar" />
<file name="commons-logging-1.1.1.jar"/>
<file name="commons-pool-1.5.1.jar"/>
Code Snippet (part that should be loading via JPA):
//ADDED FOR DROOLS PERSISTENCE
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("jdbc/testDS1");
ds.setClassName("org.h2.jdbcx.JdbcDataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user","sa");
ds.getDriverProperties().put("password", "sasa");
ds.getDriverProperties().put("URL",
"jdbc:h2:file:/var/tmp/process-instance-db");
ds.init();
try {
Context ctx = new InitialContext();
ctx.createSubcontext("jdbc");
ctx.rebind("jdbc/testDS1",ds);
ctx.close();
} catch (NamingException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
}
Environment env = KnowledgeBaseFactory.newEnvironment();
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY,emf);
//grab a session
LOG.debug("Initializing a new StatefulKnowledgeSession...");
//this.ksession = this.kbase.newStatefulKnowledgeSession();
this.ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase,null,env);
And finally the persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
<!--persistence-unit name="ProcessService">
<jta-data-source>java:/DefaultDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit-->
<persistence-unit name="org.drools.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testDS1</jta-data-source>
<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.JPAPersistedVariable</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.SerializablePersistedVariable</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
Any help would be appreciated. This is getting rather frustrating.
--
View this message in context: http://n3.nabble.com/Drools-Persistence-Problem-tp114186p114186.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
Re: [rules-users] Problem using BRMS and Knowledge Agent
by HonorGod
Is this issue resolved for you yet?
Thank You!
hockey_dave wrote:
>
> Changing the changeset xml doesn't work for me. I'm using 5.1.0.M1 and I
> now get this error.
>
> [#|2009-10-26T08:54:44.070-0400|INFO|sun-appserver2.1|javax.enterprise.system.st
> ream.out|_ThreadID=22;_ThreadName=RTSellersServlet;|
> (null: 4, 66): SchemaLocation: schemaLocation value =
> 'http://drools.org/drools-
> 5.0/change-set.xsd' must have even number of URI's.|#]
>
> [#|2009-10-26T08:54:44.070-0400|INFO|sun-appserver2.1|javax.enterprise.system.st
> ream.out|_ThreadID=22;_ThreadName=RTSellersServlet;|
> (null: 4, 66): cvc-elt.1: Cannot find the declaration of element
> 'change-set'.|#
> ]
>
--
View this message in context: http://n3.nabble.com/Problem-using-BRMS-and-Knowledge-Agent-tp47676p11479...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
Re: [rules-users] How to create nested rules in Drool Guvnor
by malkhafaji
Marc Dzaebel wrote:
>
> Correction: extends works but is obviously undocumented. It adds the when
> part of the extended rule.
>
Is the support for this keyword removed from the current version (in trunk)?
This is the first time I am trying to use 'extends' in my rules but I cannot
find ANYTHING in the documentation about it, and I have spent at least an
hour searching this forum about it and it seems like everybody is saying
that it should work to just do:
rule "Rule 2"
when
blah
then
blah
end
rule "Rule 1" extends "Rule 2"
when
blah
then
blah
end
But eclipse does not recognize "extends" as a valid keyword. Am I missing
something?
--
View this message in context: http://n3.nabble.com/How-to-create-nested-rules-in-Drool-Guvnor-tp61446p1...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
Planner/solver - POSITIVE scoring...
by Michael Neale
Hi All - FYI I have been conversing with Geoffrey on basic
solver/planner usage questions, but we are bring the discussion here
in case others can benefit.
So I am looking at using IntConstraintOccurrence, for scoring with
weights, and HardAndSoftConstraintScoreCalculator. So I can see how
NEGATIVE_HARD and NEGATIVE_SOFT scores would work, with appropriate
accumulator rules doing that etc.
What I am not sure about is ConstraintType.POSITIVE - so I want to use
that to "favour" certain aspects of a solution. So would the correct
way to use that to be to have rules that use a positive
IntConstrainOccurrence, and then do something like:
when
$softTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_SOFT, $weight : weight),
sum($weight) // Vote for
http://jira.jboss.com/jira/browse/JBRULES-1075
);
$positiveTotal: Number() from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.POSITIVE, $weight : weight),
sum($weight) // Vote for
http://jira.jboss.com/jira/browse/JBRULES-1075
);
then
scoreCalculator.setSoftConstraintsBroken($softTotal.intValue()
- $positiveTotal.intValue());
?? it seems odd - I want to use POSITIVE but I am using it to reduce
the soft constraints broken? The the higher the positive score, the
less softConstraintsBroken property of the score calculator is set -
that seems odd... or should I not use HardAndSoft if I am using
POSITIVE and NEGATIVE scoring?
--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
16 years, 2 months
doubt in using collections and nested objects
by Sudhir M
Hi All,
I have a scenario which is similar to the one detailed below
There is a class Student and each students has a list of subjects.
Each subject has a name and a flag which is an indicator of pass or
failure.
Now how can I write a rule which tells me if there are atleast 10
students who failed in a subject maths.
Thanks
sudhir.
16 years, 2 months
eval in lhs
by HonorGod
Can i have the following as one of my conditions in decision table ?
eval(convertYesOrNo("$param").equals(myObject.getFlag()))
where convertYesOrNo() is a function inside decision table.
I get the following error -
Exception e org.drools.RuntimeDroolsException: Exception executing predicate
com.barcap.efg.fine.drools.dataobject.Rule_Corporate_Action_12_0Predicate0Invoker@490d7410
org.drools.RuntimeDroolsException: Exception executing predicate
com.barcap.efg.fine.drools.dataobject.Rule_Corporate_Action_12_0Predicate0Invoker@490d7410
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:279)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:344)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:216)
at
Thanks.
--
View this message in context: http://n3.nabble.com/eval-in-lhs-tp112964p112964.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months