gpt4 book ai didi

java - Drools 流持久性 - joinTransaction 调用上没有 Activity 的 JTA 事务

转载 作者:行者123 更新时间:2023-11-29 06:14:22 25 4
gpt4 key购买 nike

我一直在尝试按照文档 Drools-Flow-Persistence 配置持久性以在 JBOSS 6.0.0.Final 上使用 drools 流但我一直收到如下异常(尽管 hibernate 确实创建了数据库模式):

java.lang.RuntimeException: Could not commit session    

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:292)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getId(CommandBasedStatefulKnowledgeSession.java:114)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at com.sample.ProcessTest.main(ProcessTest.java:101)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at com.servlet.Servlet.doGet(Servlet.java:16)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:63)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at java.lang.Thread.run(Thread.java:619)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) Caused by: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1013)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:973)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.drools.persistence.session.DefaultJpaManager.beginCommandScopedEntityManager(DefaultJpaManager.java:62)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:274)

2011-04-14 23:16:53,716 ERROR [STDERR] (http-0.0.0.0-8000-1) ... 27 more

我的 persistence.xml 如下:

<?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.drools.persistence.jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jdbc/processInstanceDS</jta-data-source>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<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>

在JBOSS中配置数据源如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/processInstanceDS</jndi-name>
<rar-name>jboss-local-jdbc.rar</rar-name>
<use-java-context>true</use-java-context>
<connection-definition>javax.sql.DataSource</connection-definition>
<jmx-invoker-name>jboss:service=invoker,type=unified</jmx-invoker-name>
<min-pool-size>0</min-pool-size>
<max-pool-size>10</max-pool-size>
<blocking-timeout-millis>30000</blocking-timeout-millis>
<idle-timeout-minutes>30</idle-timeout-minutes>
<prefill>false</prefill>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
<validate-on-match>true</validate-on-match>
<statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
<isSameRM-override-value>false</isSameRM-override-value>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
<security-domain-and-application xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<metadata/>
<local-transaction/>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
<set-tx-query-timeout>false</set-tx-query-timeout>
<query-timeout>0</query-timeout>
<url-delimiter>|</url-delimiter>
<driver-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</driver-class>
<user-name>root</user-name>
<password></password>
<connection-url>jdbc:mysql://machine:3306/mydroolsdb</connection-url>
</local-tx-datasource>
</datasources>

我的代码运行规则流:

try {
KnowledgeBase kbase = readKnowledgeBase();
// create the entity manager factory and register it in the environment
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
// create a new knowledge session that uses JPA to store the runtime state
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
int sessionId = ksession.getId();
// invoke methods on your method here
ksession.startProcess("com.sample.bpmn.hello");
ksession.dispose();
} catch (Throwable t) {
t.printStackTrace();
}

我已经把 mysql-connector-java-5.0.8-bin.jar 和 btm-1.3.2.jar 放在“%JBOSS_HOME%\common\lib”目录下

我错过了什么?我得到上述异常(即使使用 H2 db),但 hibernate 确实成功生成了数据库模式,我们将不胜感激。

最佳答案

在您的 persistence.xml 中,您似乎引用了 bitronix 事务管理器,而我怀疑如果您将其作为应用程序运行在 JBoss AS 上,您想要使用 JBoss 事务管理器:

克里斯

关于java - Drools 流持久性 - joinTransaction 调用上没有 Activity 的 JTA 事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5669998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com