2 Replies Latest reply on Aug 10, 2011 11:05 AM by francesco.pietrobelli

    Unknown error using timer in JEE

    francesco.pietrobelli

      Hi all,

      I have a JEE application with jBPM embedded and I have a process that during his execution flow he reaches a intermediate timer catch event. And so the session with that process is disposed. My problem arises when I load the session after the timer is triggered, particularly, the thrown exception is:

       

      2011-08-05 17:03:54,659 ERROR [org.drools.persistence.SingleSessionCommandService] (pool-26-thread-1) Could not commit session

      java.lang.NullPointerException

                at org.drools.persistence.jpa.JpaPersistenceContextManager.beginCommandScopedEntityManager(JpaPersistenceContextManager.java:67)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:287)

                at org.drools.persistence.jpa.JpaJDKTimerService$JpaJDKCallableJob.call(JpaJDKTimerService.java:75)

                at org.drools.persistence.jpa.JpaJDKTimerService$JpaJDKCallableJob.call(JpaJDKTimerService.java:63)

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

                at java.util.concurrent.FutureTask.run(FutureTask.java:166)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

                at java.lang.Thread.run(Thread.java:636)

       

      This is the entire stack trace and I haven't any additional information to understand what happened.

       

      Moreover the thread that throws the NPE is different from thread that loads the session. Anybody know where to find some information about jBPM threading model?

       

      I can't attach a junit test because I have this problem only when i deploy my application in JBoss5.1, whereas the same process tested with the help of JbpmJunitTestCase doesn't generate any errors.

       

      Regards,

      Francesco.

        • 1. Re: Unknown error using timer in JEE
          garytse

          Hi,

           

          You might want to check my post here, I had something related :--

           

          http://community.jboss.org/thread/170488?tstart=0

           

          Since you're using JBoss server, that should be easier.  You might want to quote your persistence.xml and the way you're initializing the StatefulKnowledgeSession. 

           

          eg.

          Mare Geldenhuys post on:

          // Change second parameter to where you get your transaction manager from

          env.set( EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager() );

           

           

          Good luck,

          • 2. Re: Unknown error using timer in JEE
            francesco.pietrobelli

            Thank of your answer, but my problem is slighty different because i use container managed transaction and i don't have NPE on TranscationManager but i have it on appScopedEntityManager of org.drools.persistence.jpa.JpaPersistenceContextManager.

             

            I can't understand why since my stateless EJB load the session specify an enviroment in this way:

             

            @Stateless
            public class .... {
                
                 @PersistenceUnit(unitName = "org.jbpm.persistence.jpa")
                 private EntityManagerFactory engineEmf;
            
                 @PostConstruct
                 public void init(){
                      ....
                      env = KnowledgeBaseFactory.newEnvironment();
                      env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, engineEmf);
                      ....
                 }
            
                 ....
                 
                 private StatefulKnowledgeSession getSessionById(int id) {
                      StatefulKnowledgeSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id, kbase, null, env);
                      log.info("Loaded session with id=" + id + ": " + ksession);
                      ksession = registerSessionStuff(ksession);
                      return ksession;
                 }
                 ....
            }
            

             

            and my persistence.xml is like this:

             

            <?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="org.jbpm.persistence.jpa" transaction-type="JTA">
                                <jta-data-source>java:myDataSource</jta-data-source>
                                <!-- Runtime classes -->
                                <class>org.drools.persistence.info.SessionInfo</class>
                                <class>org.drools.persistence.info.WorkItemInfo</class>
                                <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
              
                                <!-- BAM classes-->
                                <class>org.jbpm.process.audit.ProcessInstanceLog</class>
                                <class>org.jbpm.process.audit.NodeInstanceLog</class>
                                <class>org.jbpm.process.audit.VariableInstanceLog</class>
              
                                <properties>
                                          <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
                                          <property name="hibernate.hbm2ddl.auto" value="update" />
                                          <property name="hibernate.show_sql" value="false" />
                                          <property name="hibernate.jdbc.batch_size" value="0"/>
                                </properties>
                      </persistence-unit>
            </persistence>
            
            

             

            maybe is a bug?