JTA集成jBPM抛出'当参加另一笔交易时不能使用连接'

问题描述 投票:0回答:1

我在SpringBoot环境中集成了jBPM,发现相同的XAResource在高并发性下可以处理不同的事务。我将NarayanaDBCP组合用作我的TransactionManager和ResourceManager。在使用org.kie.internal.persistence.jpa.JPAKnowledgeService持久性KieSession或从数据库重新加载KieSession时发生异常,我发现错误是在类KieSpringTransactionManager commit方法中跟踪调用堆栈]

if (transactionContext != null && !transactionContext.isTransactionComplete()) {
            if (transactionContext.isActive()) {
                if (transactionContext != transactionRegistry.getActiveTransactionContext()) {
                    throw new SQLException("Connection can not be used while enlisted in another transaction");
                }
                return;
            }
            // transaction should have been cleared up by TransactionContextListener, but in
            // rare cases another lister could have registered which uses the connection before
            // our listener is called. In that rare case, trigger the transaction complete call now
            transactionComplete();
        }
2019-09-17 13:29:13.906  INFO 6303 --- [      Thread-38] o.h.e.internal.DefaultLoadEventListener  : HHH000327: Error performing load command : org.hibernate.exception.GenericJDBCException: could not prepare statement

org.hibernate.exception.GenericJDBCException: could not prepare statement
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.prepareQueryStatement(AbstractLoadPlanBasedLoader.java:226) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeQueryStatement(AbstractLoadPlanBasedLoader.java:190) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:188) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4269) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:511) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:481) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:222) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.event.internal.DefaultLoadEventListener.lockAndLoad(DefaultLoadEventListener.java:406) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:127) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1257) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.internal.SessionImpl.access$1900(SessionImpl.java:207) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2867) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2848) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3483) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3457) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_172]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_172]
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350) [spring-orm-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at com.sun.proxy.$Proxy95.find(Unknown Source) [na:na]
    at org.drools.persistence.jpa.JpaPersistenceContext.findSession(JpaPersistenceContext.java:75) [drools-persistence-jpa-7.26.0.Final.jar:7.26.0.Final]
    at org.drools.persistence.PersistableRunner.initExistingKnowledgeSession(PersistableRunner.java:229) [drools-persistence-jpa-7.26.0.Final.jar:7.26.0.Final]
    at org.drools.persistence.PersistableRunner.<init>(PersistableRunner.java:190) [drools-persistence-jpa-7.26.0.Final.jar:7.26.0.Final]
    at sun.reflect.GeneratedConstructorAccessor66.newInstance(Unknown Source) [na:1.8.0_172]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:1.8.0_172]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [na:1.8.0_172]
    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:122) [drools-persistence-jpa-7.26.0.Final.jar:7.26.0.Final]
    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:104) [drools-persistence-jpa-7.26.0.Final.jar:7.26.0.Final]
    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:36) [drools-persistence-jpa-7.26.0.Final.jar:7.26.0.Final]
    at org.kie.internal.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(JPAKnowledgeService.java:144) [kie-internal-7.26.0.Final.jar:7.26.0.Final]
    at jbpm.boot.kie.listener.AsyncProcessEventListener.signalProcess(AsyncProcessEventListener.java:63) [classes/:na]
    at jbpm.boot.kie.listener.AsyncProcessEventListener.lambda$mockBiz$0(AsyncProcessEventListener.java:53) [classes/:na]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_172]
Caused by: java.sql.SQLException: Connection can not be used while enlisted in another transaction
    at org.apache.commons.dbcp2.managed.ManagedConnection.updateTransactionStatus(ManagedConnection.java:89) ~[commons-dbcp2-2.5.0.jar:2.5.0]
    at org.apache.commons.dbcp2.managed.ManagedConnection.checkOpen(ManagedConnection.java:81) ~[commons-dbcp2-2.5.0.jar:2.5.0]
    at org.apache.commons.dbcp2.DelegatingConnection.prepareStatement(DelegatingConnection.java:289) ~[commons-dbcp2-2.5.0.jar:2.5.0]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    ... 37 common frames omitted
java drools jbpm xa dbcp
1个回答
0
投票

您介意提供有关您的设置的更多信息吗?例如,您使用哪种运行时策略?什么版本的jBPM和Spring可以帮助您调查问题。

© www.soinside.com 2019 - 2024. All rights reserved.