Hi all!
I need to configure my system to save the state of a
StatefulKnowledgeSession.
I'm using tomcat 6, BTM 1.3.2, Hibernate 3.4 and Postgres 8.3.
I have configured my Tomcat 6 and my jee aplication as it is described in
this post
http://docs.codehaus.org/display/BTM/Tomcat13
So I have published a DataSource called testDS1.
My persitence.xml file has the next configuration:
---------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<persistence version="1.0"
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"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit
name="com.logister.brms.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:comp/env/jdbc/testDS1</jta-data-source>
<class>org.drools.persistence.session.SessionInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop"
/>
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.JTATransactionFactory" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
---------------------------------------------------------------------------------------------
And my code for creating the StatefulKnowledgeSession is the next below:
(The same is shown in the Chapter 5 persitence in the web
http://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/tr...
).
---------------------------------------------------------------------------------------------
KnowledgeBase kbase = null;
StatefulKnowledgeSession ksession = null;
kbase = util.readKnowledgeBase(); // This method reads all the rf (flow)
files.
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("com.logister.brms.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null,
env);
int sessionId = ksession.getId();
---------------------------------------------------------------------------------------------
My problem is that I get the next Error, but the table sessioninfo is
automatically created.
javax.persistence.PersistenceException: [PersistenceUnit:
com.logister.brms.jpa]
Unable to build EntityManagerFactory
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:677)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(Hib
ernatePersistence.java:126)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:52)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:34)
at com.logister.BRMS.BrmsServlet.doPost(BrmsServlet.java:124)
at com.logister.BRMS.BrmsServlet.doGet(BrmsServlet.java:59)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:293)
at
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcesso
r.java:859)
at
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.pr
ocess(Http11AprProtocol.java:574)
at
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:15
27)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.HibernateException: Could not obtain BTM
transaction ma
nager instance
at
org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionM
anager(BTMTransactionManagerLookup.java:50)
at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
357)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
ionConfiguration.java:867)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:669)
... 19 more
Caused by: java.lang.ClassCastException:
bitronix.tm.BitronixTransactionManager
at
org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionM
anager(BTMTransactionManagerLookup.java:47)
... 23 more
Any idea? I have looked for a solution and I have tried differents
configurations in my persistence.xml file but in fact I have always received
a java.lang.ClassCastException.
Thanks in advance.
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/ClassCastException-BT...
Sent from the Drools - Dev mailing list archive at
Nabble.com.