Andres Fernandez [http://community.jboss.org/people/ysh_fdez] created the discussion
"Re: JBPM's persistence reusing existing connection" To view the discussion, visit: http://community.jboss.org/message/642648#642648 -------------------------------------------------------------- Thank very much Juan and Mauricio. Our applications create the connection as mode application managed entity manager. I'll trying to get a valid EntityManager from an instance of hibernate.Session. I will have the option to add a JTA transaction manager as plan B. We tested code that we have seen on the web, but as nothing has worked so I began to doubt. *First* way http://community.jboss.org/thread/163990 http://community.jboss.org/thread/163990 Code {{{ org.hibernate.Session session = ... Configuration cfg = new Configuration(); cfg.configure("/hibernate.cfg.xml"); EntityManagerFactory emf = new EntityManagerFactoryImpl(session.getSessionFactory(), PersistenceUnitTransactionType.RESOURCE_LOCAL, true, null, cfg); Environment env = KnowledgeBaseFactory.newEnvironment(); env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env); }}} Error {{{ 21/12/2011 08:38:10 [ERROR] (org.drools.persistence.SingleSessionCommandService) - Could not commit session java.lang.NullPointerException at org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:205) }}}} *Second* way http://docs.jboss.org/drools/release/5.3.0.CR1/drools-expert-docs/html/ch04.html#d0e2134 http://docs.jboss.org/drools/release/5.3.0.CR1/drools-expert-docs/html/ch04.html#d0e2134 http://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/runtime/StatefulKnowledgeSession.html http://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/runtime/StatefulKnowledgeSession.html Code {{{ org.hibernate.Session session = ... StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); ksession.setGlobal("hbnSession", session); }}} Error {{{ java.lang.RuntimeException: Unexpected global [hbnSession] at org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:586) at org.drools.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessionImpl.java:332) }}} If I get the code that works I'll put it here. Greetings -------------------------------------------------------------- Reply to this message by going to Community [http://community.jboss.org/message/642648#642648] Start a new discussion in jBPM at Community [http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
