0 Replies Latest reply on Sep 24, 2014 4:10 AM by Yogesh Gupta

    Issue with Session in JBPM5.4 (Tomcat+Bitronix+jbpm5.4+Spring)

    Yogesh Gupta Newbie

      Dear All,

      I'm facing error related to Ksession.

      My Environment is : Spring3.2+jbpm5.4+tomcat7+Bitronix

      Below are the error I'm getting:

       

       

      Sep 23, 2014 4:29:27 PM org.drools.persistence.SingleSessionCommandService rollbackTransaction

      SEVERE: Could not commit session

      org.hibernate.SessionException: Session is closed!

              at org.hibernate.internal.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:129)

              at org.hibernate.internal.SessionImpl.getTransactionCoordinator(SessionImpl.java:2008)

              at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1208)

              at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1183)

              at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.doJoinTransaction(ExtendedEntityManagerCreator.java:382)

              at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)

              at $Proxy646.joinTransaction(Unknown Source)

              at org.drools.persistence.jpa.JpaPersistenceContext.joinTransaction(JpaPersistenceContext.java:37)

              at org.drools.container.spring.beans.persistence.DroolsSpringJpaManager.beginCommandScopedEntityManager(DroolsSpringJpaManager.java:116)

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

              at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:223)

              at com.cmc.jbpm.ProcessEngine.startProcess(ProcessEngine.java:49)

              at com.cmc.common.jbpmservice.impl.JbpmServiceImpl.initiateWorkflowJbpm(JbpmServiceImpl.java:38)

              at com.cmc.marriagegift.controllerservice.MarriageGiftJbpmActionService.createProcess(MarriageGiftJbpmActionService.java:122)

              at sun.reflect.GeneratedMethodAccessor570.invoke(Unknown Source)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)

              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)

              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)

              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

              at $Proxy675.createProcess(Unknown Source)

              at com.cmc.marriagegift.controller.MarriageGiftJbpmActionController.createProcess(MarriageGiftJbpmActionController.java:79)

              at sun.reflect.GeneratedMethodAccessor567.invoke(Unknown Source)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)

              at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)

              at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)

              at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:746)

              at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687)

              at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

              at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)

              at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)

              at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)

              at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:822)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)

              at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)

              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

              at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

              at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)

              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)

              at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

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

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

       

       

       

      My Spring Configuration File is :

       

       

      <?xml version="1.0" encoding="UTF-8"?>

       

       

      <beans xmlns="http://www.springframework.org/schema/beans"

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"

        xmlns:tx="http://www.springframework.org/schema/tx"

        xmlns:drools="http://drools.org/schema/drools-spring"

        xmlns:aop="http://www.springframework.org/schema/aop"

         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

           http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd

          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

          http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring-1.3.0.xsd

       

       

          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

       

       

        

        <aop:aspectj-autoproxy />

       

        <!-- Setting up of datasource -->

       

        <bean id="dataSource"

              class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">

               <property name="className"

                    value="oracle.jdbc.xa.client.OracleXADataSource" />    

                  

              <property name="uniqueName" value="jdbc/jbpm-ds" />

              <property name="minPoolSize" value="5" />

              <property name="maxPoolSize" value="65" />

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

               <property name="testQuery" value="SELECT 1 FROM DUAL" />

              <property name="driverProperties">

             

             <props>

        DB Properties

        </props>

            

       

        <!-- Creation of Entity Manager Factory -->

       

       

       

       

        <bean id="jbpmEMF"

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

          <property name="jpaVendorAdapter">

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

          </property>

          <property name="dataSource">

        <ref bean="dataSource" />

        </property>

          <property name="persistenceXmlLocation" value="classpath*:persistence.xml" />

        

          <property name="persistenceUnitName" value="org.jbpm.persistence.local"></property> <!-- org.jbpm.runtime -->

        </bean>

        

        <bean id="btmConfig" factory-method="getConfiguration"

        class="bitronix.tm.TransactionManagerServices">

        </bean>

       

        <!-- <bean id="BitronixTransactionManager" factory-method="getTransactionManager"

        class="bitronix.tm.TransactionManagerServices">

        </bean>  -->

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

        class="bitronix.tm.TransactionManagerServices"

        depends-on="btmConfig,dataSource,dataSourceB" destroy-method="shutdown">

        </bean>

        

        

        <bean id="jbpmTxManager"

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

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

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

        </bean>

       

        <!-- Human Task Spring Transaction Manager -->

        <bean id="htTxManager" class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager">

        <constructor-arg ref="jbpmTxManager" />

        </bean>

       

        <bean id="systemEventListener" class="org.drools.SystemEventListenerFactory"  factory-method="getSystemEventListener" />

        <bean id="internalTaskService" class="org.jbpm.task.service.TaskService">

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

        </bean>

        

        <bean id="springTaskSessionFactory" class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl" init-method="initialize" depends-on="internalTaskService">

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

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

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

        <property name="taskService" ref="internalTaskService" />

        </bean>

       

       

        <bean id="taskService" class="org.jbpm.task.service.local.LocalTaskService"

        depends-on="internalTaskService">

        <constructor-arg ref="internalTaskService" />

        </bean>

       

       

       

       

       

       

       

        <bean id="localHTWorkItemHandler" class="org.jbpm.process.workitem.wsht.LocalHTWorkItemHandler" init-method="connect" depends-on="ksession1">

        <constructor-arg  ref="ksession1" />

        <constructor-arg ref="taskService" />

        </bean>

       

        <bean id="wshtHandler" class="com.cmc.jbpm.SelfRegisteringLocalHTHandler"

          init-method="connect">

          <constructor-arg ref="taskService"></constructor-arg>

          <constructor-arg ref="ksession1"></constructor-arg>

        </bean>

       

       

       

          <drools:ksession id="ksession1" type="stateful" kbase="kbase">

        <drools:configuration>

        <drools:jpa-persistence>

        <drools:transaction-manager ref="jbpmTxManager" />

        <drools:entity-manager-factory ref="jbpmEMF" />

        </drools:jpa-persistence>

       

        </drools:configuration>

        </drools:ksession>

       

        <drools:kbase id="kbase">

           <drools:resources>

              <drools:resource type="BPMN2" source="classpath:abc.bpmn" />

              <drools:resource type="BPMN2" source="classpath:def.bpmn" />

             

           </drools:resources>

        </drools:kbase>

       

       

       

       

        <bean class="com.abc.jbpm.ProcessEngine" id="processEngine">

          <property name="ksession" ref="ksession1"></property>

          <property name="jpaLogger" ref="jpaDbLogger" ></property>

        </bean>

       

        <bean class="com.abc.jbpm.HumanTaskEngine" id="humanTaskEngine">

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

          <property name="tskService" ref="internalTaskService"></property>

        </bean>

       

        <!-- for workflowMonitoring -->

        <bean id="jpaDbLogger" class="org.jbpm.process.audit.JPAWorkingMemoryDbLogger">

        <constructor-arg ref="ksession1"></constructor-arg>

        </bean>

       

         <bean name="taskSummary" class="org.jbpm.task.query.TaskSummary"/>

        

         

        

        <!--  <tx:annotation-driven transaction-manager="jbpmTxManager"   /> -->

        

        

        

        

        

         <!-- Creation of second persistence unit For JTA configuration over 2 databases -->

        

        

         <bean id="essBpmEMF"

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

          <property name="jpaVendorAdapter">

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

          </property>

          <property name="dataSource">

        <ref bean="dataSourceB" />

        </property>

          <property name="persistenceXmlLocation" value="classpath*:persistence.xml" />

        

          <property name="persistenceUnitName" value="PersistenceUnitB"></property> <!-- org.jbpm.runtime -->

        </bean>

        

       

       

       

        <bean id="dataSourceB"

              class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">

               <property name="className"

                    value="oracle.jdbc.xa.client.OracleXADataSource" />          

              <property name="uniqueName" value="jdbc/essBpmDS" />

              <property name="minPoolSize" value="5" />

              <property name="maxPoolSize" value="250" />

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

               <property name="testQuery" value="SELECT 1 FROM DUAL" />

              <property name="driverProperties">

             

        <props>

        DB Properties

        </props>

            

               </property>

          </bean>

        

                  <tx:annotation-driven transaction-manager="jbpmTxManager"   />

        

               </beans>

       

       

       

      Please Help me to resolve this issue ASAP.

       

      Thanks in advance.