Why do I get warning "TwoPhaseCoordinator.afterCompletion - returned failure" when calling web service that is a JBoss Seam component.

Solution Verified - Updated -

Environment

  • JBoss Enterprise Application Platform (EAP)

    • 5.0.0.GA
  • Seam 2.x

Issue

  • Whenever call the method executing the call getting the following message in the log:
    [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4] TwoPhaseCoordinator.afterCompletion - returned failure for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImpl

The server.log doesn't say much. Here's the section concerned:

13:05:32,838 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
13:05:32,859
INFO  [ServerImpl] JBoss (Microcontainer) [5.0.0.GA (build:
SVNTag=JBPAPP_5_0_0_GA date=200910202128)] Started in 1m:53s:766ms
13:06:12,696 INFO  [CheckPersonServiceImpl] Checking person: person1
13:06:13,207 INFO  [CheckPersonDao] preparing procedure call ... 
13:06:13,208 INFO  [CheckPersonDao] Executing stored procedure: ispfind
13:06:13,569 INFO  [CheckPersonDao] Executing procedure with request: com.aaa.bbb.ws.CheckPersonRequest@1432c0c
13:06:13,751 INFO  [CheckPersonDao] response created : com.aaa.bbb.ws.CheckPersonResponse@8f2019
13:06:13,751 INFO  [CheckPersonDao] Connection open: true
13:06:13,751 INFO  [CheckPersonDao] Releasing database resources.
13:06:13,751 INFO  [CheckPersonDao] Has borrowed connections ?: false
13:06:13,786
WARN  [arjLoggerI18N]
[com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4]
TwoPhaseCoordinator.afterCompletion - returned failure for
com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1cdccc3

As you can see we called the webservice directly after startup of the server. The class is a stateless session bean with the following annotations:

@Stateless
@WebService(endpointInterface = "com.my.abc.ws.CheckPersonPortType")
@Name("checkPersonService")
public class CheckPersonServiceImpl implements CheckPersonPortType {

Resolution

  • To allow Seam to intercept web service requests so that the necessary Seam contexts can be created for the request, a special SOAP handler must be configured; org.jboss.seam.webservice.SOAPRequestHandler is a SOAPHandler implementation that does the work of managing Seam's lifecycle during the scope of a web service request.

A special configuration file, standard-jaxws-endpoint-config.xml should be placed into the META-INF directory of the jar file that contains the web service classes.  This file contains the following SOAP handler configuration:

<jaxws-config xmlns="urn:jboss:jaxws-config:2.0" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
              xmlns:javaee="http://java.sun.com/xml/ns/javaee"
              xsi:schemaLocation="urn:jboss:jaxws-config:2.0 jaxws-config_2_0.xsd">
   <endpoint-config>
      <config-name>Seam WebService Endpoint</config-name>
      <pre-handler-chains>
         <javaee:handler-chain>
            <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
            <javaee:handler>
               <javaee:handler-name>SOAP Request Handler</javaee:handler-name>
               <javaee:handler-class>org.jboss.seam.webservice.SOAPRequestHandler</javaee:handler-class>
            </javaee:handler>
         </javaee:handler-chain>
      </pre-handler-chains>
   </endpoint-config>
</jaxws-config>

Reference: Web Services in Seam

Root Cause

  • The warning is coming about because there is no event context active at the end of the transaction during synchronization.

  • There is no active event context because the event context is only temporary and destroyed before the end of the transaction. It is temporary because the call to the seam components is invoked outside of a Seam context.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.