在 Jbpm 中使用两个 xa-datasource 时出现问题

发布于 2024-07-21 08:17:21 字数 8897 浏览 8 评论 0原文

我正在使用 Seam、JBoss Jbpm 和 Resteasy。 我有一个非常简单的流程定义:

<start-state name="create">
    <transition name="send" to="inbox" />
</start-state>
<node name="inbox">
    <action expression="#{test.sayHello}" />
    <transition name="acknowledge" to="acknowledged" />
</node>
<end-state name="acknowledged" />

这是应该启动流程的类


@Name("webservice")
@Path("/webservice")
@AutoCreate
public class WebService
{
    @GET
    @CreateProcess(definition="Blah")
    @Transactional
    public String getSomething() throws Exception
    {
        ...
    }

}

流程定义也非常简单: http://docs.jboss.org/jbpm/xsd/jpdl-3.2.xsd” 名称=“废话”>

<start-state name="create">
    <transition name="send" to="inbox" />
</start-state>
<node name="inbox">
    <action expression="#{test.sayHello}" />
    <transition name="acknowledge" to="acknowledged" />
</node>
<end-state name="acknowledged" />

然后,当我尝试调用 WebService 时,我得到以下堆栈跟踪:

10:38:41,443 错误 [STDERR] 引起:org.jbpm.JbpmException:找不到流程定义“Blah” 10:38:41,443 错误 [STDERR] 在 org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:158) 10:38:41,443 错误 [STDERR] 在 org.jbpm.JbpmContext.newProcessInstanceForUpdate(JbpmContext.java:417) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.bpm.BusinessProcess.createProcess(BusinessProcess.java:134) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.bpm.BusinessProcess.createProcess(BusinessProcess.java:123) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.bpm.BusinessProcessInterceptor.afterInitation(BusinessProcessInterceptor.java:108) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.intercept.SeamInvocalContext.proceed(SeamInvocalContext.java:68) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:95) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.util.Work.workInTransaction(Work.java:47) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:89) 10:38:41,444 错误 [STDERR] 在 org.jboss.seam.intercept.SeamInvocalContext.proceed(SeamInvocalContext.java:68) 10:38:41,445 错误 [STDERR] 在 org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) 10:38:41,445 错误 [STDERR] 在 org.jboss.seam.intercept.SeamInvocalContext.proceed(SeamInvocalContext.java:68) 10:38:41,445 错误 [STDERR] 在 org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) 10:38:41,445 错误 [STDERR] 在 org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) 10:38:41,445 错误 [STDERR] 在 org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) 10:38:41,445 错误 [STDERR] 在 com.locaweb.infra.gridserver.resources.ServerResource_$$_javassist_5.getServerResource(ServerResource_$$_javassist_5.java) 10:38:41,445 错误 [STDERR] 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 10:38:41,445 错误 [STDERR] 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 10:38:41,447 错误 [STDERR] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 10:38:41,447 错误 [STDERR] 在 java.lang.reflect.Method.invoke(Method.java:585) 10:38:41,447 错误 [STDERR] 在 org.resteasy.MethodInjectorImpl.invoke(MethodInjectorImpl.java:72) 10:38:41,447 错误 [STDERR] ... 28 个以上 10:38:41,448 错误 [STDERR] 引起:org.hibernate.exception.GenericJDBCException:无法打开连接 10:38:41,449 错误 [STDERR] 在 org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) 10:38:41,449 错误 [STDERR] 在 org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) 10:38:41,449 错误 [STDERR] 在 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) 10:38:41,449 错误 [STDERR] 在 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) 10:38:41,449 错误 [STDERR] 在 org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426) 10:38:41,449 错误 [STDERR] 在 org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) 10:38:41,449 错误 [STDERR] 在 org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.Loader.doQuery(Loader.java:673) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.Loader.doList(Loader.java:2220) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.Loader.list(Loader.java:2099) 10:38:41,450 错误 [STDERR] 在 org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378) 10:38:41,451 错误 [STDERR] 在 org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338) 10:38:41,451 错误 [STDERR] 在 org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) 10:38:41,451 错误 [STDERR] 在 org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) 10:38:41,451 错误 [STDERR] 在 org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) 10:38:41,451 错误 [STDERR] 在 org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811) 10:38:41,451 错误 [STDERR] 在 org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:154) 10:38:41,451 错误 [STDERR] ... 49 更多 10:38:41,452 错误 [STDERR] 原因为:org.jboss.util.NestedSQLException:无法在输入元感知对象时加入事务!; - 嵌套的 throwable: (javax.transaction.SystemException: java.lang.Throwable: 无法征用资源,请参阅前面的警告。tx=TransactionImple < ac, BasicAction: 7f000101:d2f8:4a1fe246:4e status: ActionStatus.ABORT_ONLY > ); - 嵌套的 throwable: (org.jboss.resource.JBossResourceException: 在输入元感知对象时无法登记事务!; - 嵌套的 throwable: (javax.transaction.SystemException: java.lang.Throwable: 无法登记资源,请参阅以前的警告。 tx=TransactionImple < ac,BasicAction:7f000101:d2f8​​:4a1fe246:4e 状态:ActionStatus.ABORT_ONLY >)) 10:38:41,453 错误 [STDERR] 在 org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95) 10:38:41,453 错误 [STDERR] 在 org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69) 10:38:41,453 错误 [STDERR] 在 org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423) 10:38:41,453 错误 [STDERR] ... 64 更多 10:38:41,455 错误 [STDERR] 引起:org.jboss.resource.JBossResourceException:无法在输入元感知对象时登记事务!; - 嵌套的 throwable: (javax.transaction.SystemException: java.lang.Throwable: 无法征用资源,请参阅前面的警告。tx=TransactionImple < ac, BasicAction: 7f000101:d2f8:4a1fe246:4e status: ActionStatus.ABORT_ONLY > ) 10:38:41,459 错误 [STDERR] 在 org.jboss.resource.connectionmanager.TxConnectionManager.drivenConnectionReconnected(TxConnectionManager.java:358) 10:38:41,460 错误 [STDERR] 在 org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:524) 10:38:41,460 错误 [STDERR] 在 org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:405) 10:38:41,460 错误 [STDERR] 在 org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849) 10:38:41,460 错误 [STDERR] 在 org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89) 10:38:41,460 错误 [STDERR] ... 66 更多 10:38:41,461 错误 [STDERR] 原因为:javax.transaction.SystemException:java.lang.Throwable:无法登记资源,请参阅前面的警告。 tx=TransactionImple <; ac,BasicAction:7f000101:d2f8​​:4a1fe246:4e状态:ActionStatus.ABORT_ONLY> 10:38:41,462 错误 [STDERR] 在 org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:759) 10:38:41,462 错误 [STDERR] 在 org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:592) 10:38:41,462 错误 [STDERR] 在 org.jboss.resource.connectionmanager.TxConnectionManager.drivenConnectionReconnected(TxConnectionManager.java:352) 10:38:41,462 错误 [STDERR] ... 70 更多

我正在使用带有两个 xa 数据源(一个用于我的数据库,一个用于 Jbpm 数据库)和驱动程序 net.sourceforge.jtds.jdbcx.JtdsDataSource 的 SQLServer 数据库。 Web 服务确实使用非 jbpm 数据库。

当我在没有 getSomething() 方法访问非 jbpm 数据库的 hibernate 会话的情况下尝试此操作时,它可以正常工作。 但是,如果我注入会话并尝试同样的事情,那么大多数时候都不起作用。

有谁知道发生了什么事?

I'm using Seam, JBoss Jbpm and Resteasy. I have a very simple process definition:

<start-state name="create">
    <transition name="send" to="inbox" />
</start-state>
<node name="inbox">
    <action expression="#{test.sayHello}" />
    <transition name="acknowledge" to="acknowledged" />
</node>
<end-state name="acknowledged" />

This is the class that supposedly would start the process


@Name("webservice")
@Path("/webservice")
@AutoCreate
public class WebService
{
    @GET
    @CreateProcess(definition="Blah")
    @Transactional
    public String getSomething() throws Exception
    {
        ...
    }

}

The process definition is also very simple:
http://docs.jboss.org/jbpm/xsd/jpdl-3.2.xsd"
name="Blah">

<start-state name="create">
    <transition name="send" to="inbox" />
</start-state>
<node name="inbox">
    <action expression="#{test.sayHello}" />
    <transition name="acknowledge" to="acknowledged" />
</node>
<end-state name="acknowledged" />

Then, when I try to call the WebService, I get the following Stack Trace:

10:38:41,443 ERROR [STDERR] Caused by: org.jbpm.JbpmException: couldn't find process definition 'Blah' 10:38:41,443 ERROR [STDERR] at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:158) 10:38:41,443 ERROR [STDERR] at org.jbpm.JbpmContext.newProcessInstanceForUpdate(JbpmContext.java:417) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.bpm.BusinessProcess.createProcess(BusinessProcess.java:134) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.bpm.BusinessProcess.createProcess(BusinessProcess.java:123) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.bpm.BusinessProcessInterceptor.afterInvocation(BusinessProcessInterceptor.java:108) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:95) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.util.Work.workInTransaction(Work.java:47) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:89) 10:38:41,444 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 10:38:41,445 ERROR [STDERR] at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) 10:38:41,445 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 10:38:41,445 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) 10:38:41,445 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) 10:38:41,445 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) 10:38:41,445 ERROR [STDERR] at com.locaweb.infra.gridserver.resources.ServerResource_$_javassist_5.getServerResource(ServerResource_$_javassist_5.java) 10:38:41,445 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:38:41,445 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 10:38:41,447 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 10:38:41,447 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585) 10:38:41,447 ERROR [STDERR] at org.resteasy.MethodInjectorImpl.invoke(MethodInjectorImpl.java:72) 10:38:41,447 ERROR [STDERR] ... 28 more 10:38:41,448 ERROR [STDERR] Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection 10:38:41,449 ERROR [STDERR] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) 10:38:41,449 ERROR [STDERR] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) 10:38:41,449 ERROR [STDERR] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) 10:38:41,449 ERROR [STDERR] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) 10:38:41,449 ERROR [STDERR] at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426) 10:38:41,449 ERROR [STDERR] at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) 10:38:41,449 ERROR [STDERR] at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.Loader.doQuery(Loader.java:673) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.Loader.doList(Loader.java:2220) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.Loader.list(Loader.java:2099) 10:38:41,450 ERROR [STDERR] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378) 10:38:41,451 ERROR [STDERR] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338) 10:38:41,451 ERROR [STDERR] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) 10:38:41,451 ERROR [STDERR] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) 10:38:41,451 ERROR [STDERR] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) 10:38:41,451 ERROR [STDERR] at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811) 10:38:41,451 ERROR [STDERR] at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:154) 10:38:41,451 ERROR [STDERR] ... 49 more 10:38:41,452 ERROR [STDERR] Caused by: org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000101:d2f8:4a1fe246:4e status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000101:d2f8:4a1fe246:4e status: ActionStatus.ABORT_ONLY >)) 10:38:41,453 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95) 10:38:41,453 ERROR [STDERR] at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69) 10:38:41,453 ERROR [STDERR] at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423) 10:38:41,453 ERROR [STDERR] ... 64 more 10:38:41,455 ERROR [STDERR] Caused by: org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000101:d2f8:4a1fe246:4e status: ActionStatus.ABORT_ONLY >) 10:38:41,459 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:358) 10:38:41,460 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:524) 10:38:41,460 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:405) 10:38:41,460 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849) 10:38:41,460 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89) 10:38:41,460 ERROR [STDERR] ... 66 more 10:38:41,461 ERROR [STDERR] Caused by: javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000101:d2f8:4a1fe246:4e status: ActionStatus.ABORT_ONLY > 10:38:41,462 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:759) 10:38:41,462 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:592) 10:38:41,462 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:352) 10:38:41,462 ERROR [STDERR] ... 70 more

I'm using a SQLServer Database with two xa-datasources (one for my database and one for Jbpm's Database) with the driver net.sourceforge.jtds.jdbcx.JtdsDataSource. The webservice does use the non-jbpm database.

When I try this without the getSomething() method accessing the hibernate's session of the non-jbpm database it works normally. However, if I inject the session and try the same thing it most of the time doesn't work.

Does anyone know what is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文