2 Replies Latest reply on Feb 24, 2012 6:37 AM by liliana.iovanovici

    NullPointerException when trying to configure jbpm5 with Spring 3.0 and Persistence

    liliana.iovanovici Newbie

      Hi,

       

      I am trying to configure Spring 3.0 with JBPM 5 and Persistence:

       

       

                <jbpm:ksession id="persistentKSession" type="stateful"

                          kbase="kbase">

                          <jbpm:configuration>

                                    <jbpm:jpa-persistence>

                                              <jbpm:transaction-manager ref="transactionManager" />

                                              <jbpm:entity-manager-factory ref="entityManagerFactory" />

                                    </jbpm:jpa-persistence>

                          </jbpm:configuration>

                </jbpm:ksession>

       

       

                <bean id="entityManagerFactory"

                          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

                          <property name="persistenceUnitName" value="oracle" />

                </bean>

       

       

                <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">

                          <property name="entityManagerFactory" ref="entityManagerFactory" />

                </bean>

      </beans>

       

       

      When I trying to create the context:

       

      new ClassPathXmlApplicationContext("conf.xml");

       

      I got an error:

      Caused by: java.lang.NullPointerException

                at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstances(JPAProcessInstanceManager.java:97)

                at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstances(ProcessRuntimeImpl.java:200)

                at org.drools.common.AbstractWorkingMemory.getProcessInstances(AbstractWorkingMemory.java:1093)

                at org.jbpm.marshalling.impl.ProcessMarshallerImpl.writeProcessInstances(ProcessMarshallerImpl.java:32)

                at org.drools.marshalling.impl.OutputMarshaller.writeSession(OutputMarshaller.java:158) ...

       

      Does anybody know what I am doing wrog?

       

      Thanks.

        • 1. Re: NullPointerException when trying to configure jbpm5 with Spring 3.0 and Persistence
          liliana.iovanovici Newbie

          I was trying to configure persistence in other way, using Bitronix. My spring-conf.xml file is:

           

           

           

                    <bean id="transactionManager"

                              class="org.springframework.transaction.jta.JtaTransactionManager">

                              <property name="transactionManager" ref="bitronixTransactionManager" />

                              <property name="userTransaction" ref="bitronixTransactionManager" />

                    </bean>

           

           

                    <bean id="bitronixTransactionManager" factory-method="getTransactionManager"

                              class="bitronix.tm.TransactionManagerServices" depends-on="transactionManager"

                              destroy-method="shutdown" />

           

           

                    <bean id="entityManagerFactory"

                              class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

                              <property name="persistenceUnitName" value="oracle" />

                              <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />

                              <property name="jpaVendorAdapter">

                                        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

                                                  <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />

                                                  <property name="showSql" value="true" />

                                                  <property name="generateDdl" value="false" />

                                        </bean>

                              </property>

                    </bean>

           

           

                    <jbpm:kbase id="kbase">

                              <jbpm:resources>

                                        <jbpm:resource type="BPMN2" source="classpath:Hi.bpmn" />

                              </jbpm:resources>

                    </jbpm:kbase>

           

           

                    <jbpm:ksession id="persistentKSession" type="stateful"

                              kbase="kbase">

                              <jbpm:configuration>

                                        <jbpm:jpa-persistence>

                                                  <jbpm:transaction-manager ref="transactionManager" />

                                                  <jbpm:entity-manager-factory ref="entityManagerFactory" />

                                        </jbpm:jpa-persistence>

                              </jbpm:configuration>

                    </jbpm:ksession>

           

           

          And persistence.xml file is:

           

          <persistence-unit name="oracle" transaction-type="JTA">

              <provider>org.hibernate.ejb.HibernatePersistence</provider>

              <jta-data-source></jta-data-source>

              <mapping-file>META-INF/JBPMorm.xml</mapping-file>

              <class>org.drools.persistence.info.SessionInfo</class>

              <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

              <class>org.drools.persistence.info.WorkItemInfo</class>

             

               <properties>

                <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>

                <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>

                <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:xe" />

                <property name="hibernate.connection.username" value="apsfsample"/>

                <property name="hibernate.connection.password" value="apsf"/>

                <property name="hibernate.connection.autocommit" value="false" />

                <property name="hibernate.max_fetch_depth" value="3"/>

                <property name="hibernate.hbm2ddl.auto" value="create" />

                <property name="hibernate.show_sql" value="true" />

                <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>

              </properties>

             

            </persistence-unit>

          </persistence>

           

          I steel got an exeption. It seems that the session can be commited in database. The error is:

           

          11:14:25,437 ERROR SingleSessionCommandService:313 - Could not commit session

          java.lang.NullPointerException

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

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

                    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

                    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)

                    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)

                    at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:122)

                    at org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory.internalAfterPropertiesSet(StatefulKnowledgeSessionBeanFactory.java:82)

                    at org.drools.container.spring.beans.AbstractKnowledgeSessionBeanFactory.afterPropertiesSet(AbstractKnowledgeSessionBeanFactory.java:108)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)

                    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)

                    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

                    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)

                    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)

                    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)

                    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)

                    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)

                    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

                    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

           

          Does anybody know this error?

           

          Thanks.

          • 2. Re: NullPointerException when trying to configure jbpm5 with Spring 3.0 and Persistence
            liliana.iovanovici Newbie

            OK. I resolve this problem using drools-persistence-jpa version 5.3.1 not 5.2.0.