1 Reply Latest reply on Oct 23, 2012 1:58 AM by jian zhang

    jbpm5.3 集成 spring

    jian zhang Newbie

      信息: Initializing Spring root WebApplicationContext

      0    23/10 10:47:51,175[localhost-startStop-1] ERROR drools.persistence.SingleSessionCommandService.rollbackTransaction  - Could not commit session

      java.lang.RuntimeException: Unable to begin transaction

      at org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:56)

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

      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.buildCommandService(KnowledgeStoreServiceImpl.java:129)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)

      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)

      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)

      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)

      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)

      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

      at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1105)

      at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1664)

      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

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

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

      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:619)

      Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)

      at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)

      at org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:48)

      ... 38 more

      Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

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

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

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

      at $Proxy30.getTransaction(Unknown Source)

      at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)

      at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:326)

      ... 40 more

      15   23/10 10:47:51,190[localhost-startStop-1] ERROR web.context.ContextLoader.initWebApplicationContext  - Context initialization failed

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ksession': Invocation of init method failed; nested exception is java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

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

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

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

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

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

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

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

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

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

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

      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)

      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)

      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)

      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)

      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)

      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

      at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1105)

      at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1664)

      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

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

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

      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:619)

      Caused by: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

      at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)

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

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

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

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

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

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

      ... 26 more

      Caused by: java.lang.reflect.InvocationTargetException

      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.buildCommandService(KnowledgeStoreServiceImpl.java:129)

      ... 32 more

      Caused by: java.lang.RuntimeException: Unable to begin transaction

      at org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:56)

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

      ... 37 more

      Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)

      at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)

      at org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:48)

      ... 38 more

      Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

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

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

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

      at $Proxy30.getTransaction(Unknown Source)

      at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)

      at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:326)

      ... 40 more

      2012-10-23 10:47:51 org.apache.catalina.core.StandardContext listenerStart

      严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ksession': Invocation of init method failed; nested exception is java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

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

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

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

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

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

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

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

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

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

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

      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)

      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)

      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)

      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)

      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)

      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

      at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1105)

      at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1664)

      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

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

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

      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:619)

      Caused by: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

      at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)

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

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

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

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

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

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

      ... 26 more

      Caused by: java.lang.reflect.InvocationTargetException

      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.buildCommandService(KnowledgeStoreServiceImpl.java:129)

      ... 32 more

      Caused by: java.lang.RuntimeException: Unable to begin transaction

      at org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:56)

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

      ... 37 more

      Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)

      at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)

      at org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:48)

      ... 38 more

      Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

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

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

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

      at $Proxy30.getTransaction(Unknown Source)

      at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)

      at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:326)

      ... 40 more

       

      遇到如上问题

      其中applicatoincontext.xml 文件如下:

       

       

      <bean id="mysqlDataSource"   class="org.springframework.jdbc.datasource.DriverManagerDataSource">

           <property name="driverClassName" value="com.mysql.jdbc.Driver" />

           <property name="url" value="jdbc:mysql://localhost:3306/test" />

           <property name="username" value="root" />

           <property name="password" value="catv" />

      </bean>

       

       

      <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

        <property name="jndiName">

         <value>java:comp/env/jdbc/jbpm-ds</value>

        </property>

      </bean>

       

      <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

        <property name="persistenceUnitName" value="org.jbpm.persistence.jpa" />

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

        <property name="jpaProperties">

         <props>

                      <prop key="hibernate.connection.autocommit">true</prop>

                      <prop key="hibernate.max_fetch_depth">3</prop>

                      <prop key="hibernate.show_sql">true</prop>

                      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>

                      <prop key="hibernate.hbm2ddl.auto">update</prop>

         </props>

        </property>

      </bean>

       

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

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

      </bean>

       

        <!-- JBPM configration  -->

      <jbpm:kbase id="kbase">

        <jbpm:resources>

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

        </jbpm:resources>

      </jbpm:kbase>

      <jbpm:ksession id="ksession" type="stateful" kbase="kbase">

        <jbpm:configuration>

         <jbpm:jpa-persistence>

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

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

         </jbpm:jpa-persistence>

        </jbpm:configuration>

      </jbpm:ksession>