title: Problem using two xa-datasources with Jbpm
body: <p>I'm using Seam, JBoss Jbpm and Resteasy. I have a very simple process definition:</p>
  
  <p></p>
  
  <pre><code>&lt;start-state name="create"&gt;
      &lt;transition name="send" to="inbox" /&gt;
  &lt;/start-state&gt;
  &lt;node name="inbox"&gt;
      &lt;action expression="#{test.sayHello}" /&gt;
      &lt;transition name="acknowledge" to="acknowledged" /&gt;
  &lt;/node&gt;
  &lt;end-state name="acknowledged" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is the class that supposedly would start the process</p>
  
  <pre><code>
  @Name("webservice")
  @Path("/webservice")
  @AutoCreate
  public class WebService
  {
      @GET
      @CreateProcess(definition="Blah")
      @Transactional
      public String getSomething() throws Exception
      {
          ...
      }
  
  }
  
  </code></pre>
  
  <p>The process definition is also very simple: 
  http://docs.jboss.org/jbpm/xsd/jpdl-3.2.xsd"
      name="Blah"></p>
  
  <pre><code>&lt;start-state name="create"&gt;
      &lt;transition name="send" to="inbox" /&gt;
  &lt;/start-state&gt;
  &lt;node name="inbox"&gt;
      &lt;action expression="#{test.sayHello}" /&gt;
      &lt;transition name="acknowledge" to="acknowledged" /&gt;
  &lt;/node&gt;
  &lt;end-state name="acknowledged" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Then, when I try to call the WebService, I get the following Stack Trace:</p>
  
  <p><pre><code></p>
  
  <p>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 &lt; 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 &lt; 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 &lt; 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 &lt; 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</p>
  
  <p></pre></code></p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Does anyone know what is happening?</p>