2 Replies Latest reply on May 30, 2013 2:04 AM by nhd

    Exception in transaction commit when using Web Service Atomic Transaction

      Hi all,

      I am following this tutorial from Oracle on how to use WS-AT


      A brief description about my application, which is wrote in JDeveloper:

      Two applications, one for web service and one for client.

      The WS is backed by an stateless EJB, which use JPA entity to do operations on the Oracle XE DB. The EJB transaction is container-managed, and the Entity Manager is retrieved from the JTA Datasource by using @PersistenceContext
      I put this on the EJB implementation class:

      @TransactionAttribute(value = TransactionAttributeType.MANDATORY)
      @Transactional(version = Transactional.Version.WSAT10,
      value = Transactional.TransactionFlowType.MANDATORY)

      On the client application, I use another EJB to call the WS. The proxy and all generated types are created properly by JDev. I put this on the @WebServiceReference point in the client EJB:

      @Transactional(version = Transactional.Version.WSAT10,
      value = Transactional.TransactionFlowType.MANDATORY)

      The client EJB is also annotated with:

      @TransactionAttribute(value = TransactionAttributeType.REQUIRED)

      Both applications are deployed successfully in the integrated weblogic server. But when I run the method in the client EJB that call the WS to do a persisting operation on the DB, the following exception is thrown:

      javax.ejb.EJBException: BEA1-00227DF3AF249E472B1E: javax.transaction.xa.XAException: Failed state during prepare of WS-AT XAResource ...

      which causes:

      Exception occurred during commit of transaction Name=[EJB +_the client EJB's calling method_+

      The weird thing is, if I call a method which does a simple System.out.println (no DB related operation) then no exception is thrown.

      Furthermore, if I switch both WS EJB and client EJB to use bean managed transaction, the transaction is not propagated properly, as I see that UserTransaction in the WS EJB does not have the same status as UserTransaction in the Client EJB.

      Hence I'm suspecting that there is some issue during step 4 described in the Oracle documentation:

      "Server B receives the request for Application B, detects that the header contains a transaction coordination context and determines whether it has already registered as a participant in this transaction. If it has, that transaction is resumed and if not, a new transaction is started.

      *Application B executes within the context of the imported transaction. All transactional resources with which the application interacts are enlisted with this imported transaction*."

      This is all I can find. Please help me on how to resolve the exception.