2 Replies Latest reply on Jan 20, 2012 11:51 AM by M Arnold

    Drools / jBPM with EJB3 persistence and transactions

    M Arnold Newbie

      Hi,

       

      I'm trying to use Drools and jBPM using EJB 3.0 and container managed transactions on JBoss AS 5.1.  My goal is to ensure that all jBPM work is performed in the container managed transaction.

       

      I've read the applicable documentation here, but I'm still unsure about how to achieve this.

       

      In my SLSB I have:

       

                @PersistenceUnit(unitName = "org.jbpm.persistence.jpa")

                protected EntityManagerFactory emf;


                @PersistenceContext

                protected EntityManager em;


                @Resource(mappedName = "java:/TransactionManager")

                protected TransactionManager tm;


       

      Then in a @PostConstruct I have:

       

                           env = KnowledgeBaseFactory.newEnvironment();

                           env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                           env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, em);

                           env.set(EnvironmentName.TRANSACTION_MANAGER, tm);

       

      But when I try:

       

                           ksession = JPAKnowledgeService.newStatefulKnowledgeSession(getKnowledgeBase(), null, env);


       

      I get the exception:

       

      Caused by: java.lang.ClassCastException: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate cannot be cast to org.drools.persistence.TransactionManager

              at org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:265)

              at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:115)

              ... 54 more


       

      I checked the code, and I have to say I agree. ;-)  I don't get it.  I am expected to create my own class which wraps a real javax.transaction.TransactionManager and implements org.drools.persistence.TransactionManager?  What is the correct way to do this?

       

      Thanks in advance for any help, and my apologies if I missed something obvious...

       

       

       

       

       

       

       

       

      in a stateless session bena