Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Combining single transaction between session bean & application client

800808Apr 20 2011 — edited Apr 27 2011
Hi All,

The following transaction exception was encountered when trying to combine a EmployeeSessionBean.create(Employee) method in an application client:

Application Client output

SEVERE: null
javax.transaction.SystemException: org.omg.CORBA.UNKNOWN: ----------BEGIN server-side stack trace----------
org.omg.CORBA.UNKNOWN: WARNING: IOP00010002: Unknown user exception thrown by the server - exception: org.eclipse.persistence.exceptions.DatabaseException; message:
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
Error Code: 0
Call: INSERT INTO EmployeeDB.Project (ID, NAME) VALUES (?, ?)
bind => [2 parameters bound]
Query: InsertObjectQuery(domain.Project@19d2d53) vmcid: OMG minor code: 2 completed: Maybe

at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:117)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:126)

----------END server-side stack trace---------- vmcid: OMG minor code: 2 completed: Maybe
at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:332)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:184)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:873)
at com.sun.enterprise.transaction.UserTransactionImpl.commit(UserTransactionImpl.java:208)
at applicationClient(*applicationClient.java:229*)



GF 3.1 Server log
WARNING: A system exception occurred during an invocation on EJB EmployeeSessionBean method public void ejb.EmployeeSessionBean.create(Employee) javax.ejb.EJBException
Caused by: javax.persistence.TransactionRequiredException
at ejb.EmployeeSessionBean.create(*EmployeeSessionBean.java:27*)
SEVERE: RAR5027:Unexpected exception in resource pooling
java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.

WARNING: RAR7132: Unable to enlist the resource in transaction. Returned resource to pool. Pool name: [ mysqlPool ]
WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ mysqlPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.]
WARNING: Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.



Below is the code snippet of EmployeeSessionBean & client.applicationClient:
@Stateless
//@TransactionManagement(TransactionManagementType.BEAN)
public class EmployeeSessionBean implements EmployeeService {    
    @PersistenceContext(unitName="EmployeeDB-PU") 
    private EntityManager manager;
    public void create(Employee employee) {
        manager.persist(employee);  // line 27
    }
    ………
}

import javax.transaction.UserTransaction;
public class applicationClient {
@Resource UserTransaction tx;
@EJB private static EmployeeService bean;
……..
try {
    tx.begin();
    Employee employee = new Employee()
    …….
        bean.create(employee);
} finally {
       try {
             tx.commit();  // line 229
       }
    }
}
How to relinguish transaction on EmployeeSessionBean so that all transaction could take place in applicationClient side only?
I am trying to apply examples in Pro JPA 2 to a Java EE 6 ManyToMany application.
Your assistance would be much appreciated.
Thanks,
Jack
This post has been answered by r035198x on Apr 27 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2011
Added on Apr 20 2011
22 comments
3,772 views