jQuery in Action, 2nd edition*
The moose likes EJB and other Java EE Technologies and the fly likes JBOSS 4.22 & EJB 3.0: 2 datasources and one transaction error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JBOSS 4.22 & EJB 3.0: 2 datasources and one transaction error" Watch "JBOSS 4.22 & EJB 3.0: 2 datasources and one transaction error" New topic
Author

JBOSS 4.22 & EJB 3.0: 2 datasources and one transaction error

Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
Good day,


I am new to JBOSS 4.2.2 and have run into a problem posting a trasaction. I am working with EJB 3.0 sessions and entities and have what appears to be pretty straight-forward code.

I have two different EJB modules deployed as separate JARs to my app server. Each of these EJB modules relies on a different data source and I have both data sources defined in oracle-ds.xml (see below). I make a call to EJB Module 1 and that code then makes a call to EJB Module 2 to fetch some data I need. I then use this data to populate my entity in EJB Module 1 and then I try to persist it. I would appreciate any links to documentation or any helpful hints (I ordered two books today, but they will take a few days to arrive). Here are snippets from the error.


javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
.
.
.

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: -53ef796d:67d:49fb3713:30 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: -53ef796d:67d:49fb3713:30 status: ActionStatus.ABORT_ONLY >))
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
.
.
.



Here is my oracle-ds.xml



Thanks for any help.
Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
My apologies for a redundent post.

See: http://www.coderanch.com/t/319590/EJB-Other-Java-EE-Technologies/java/EJB-Could-not-enlist-transaction

I will take a look at tx-datasource and post back the results.

Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
In my particular situation it was actually more efficient for me to define a couple of dblinks that provided access to the 2nd database. I went this route and now there is not need to attempt to manage txns across two dbs.


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JBOSS 4.22 & EJB 3.0: 2 datasources and one transaction error