[jbossws-issues] [JBoss JIRA] Commented: (JBWS-2166) WSA client handler throws exception when installing reference parameters

Andrew Dinn (JIRA) jira-events at lists.jboss.org
Wed Mar 25 05:07:22 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBWS-2166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12458974#action_12458974 ] 

Andrew Dinn commented on JBWS-2166:
-----------------------------------

HI Alessio,

I think this may well fix initializeAsReply/Destination -- however, I am not sure it is the whole fix. The xts unit tests are also failing because of a wrong document exception. Here's the exception trace.

javax.xml.ws.WebServiceException: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.processHandlerFailure(HandlerChainExecutor.java:274)
	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:153)
	at org.jboss.ws.core.jaxws.client.ClientImpl.callRequestHandlerChain(ClientImpl.java:178)
	at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:297)
	at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:291)
	at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:170)
	at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
	at $Proxy163.commitOperation(Unknown Source)
	at com.arjuna.webservices11.wsat.client.CompletionCoordinatorClient.sendCommit(CompletionCoordinatorClient.java:105)
	at com.arjuna.wst11.tests.junit.CompletionParticipantTestCase.testSendCommit(CompletionParticipantTestCase
. . .
I don't see why this is getting the error because there is no copying involved. The client code which sets up the addressing properties and endpoint is included below. What is interesting is that this error is intermittent -- although when it happen it always happens in the same place. Only 8 of the WS-T tests fail but all of them set up addressing properties and endpoints. None of the WS-C tests fail but they do the same thing.

<pre>
class CompletionParticipantTestCase {
    . . .
    public void testSendCommit()
        throws Exception
    {
        final String messageId = "testSendCommit" ;
        final AddressingProperties addressingProperties = AddressingHelper.createRequestContext(TestUtil.completionCoordinatorServiceURI, messageId) ;
        final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("1") ;
        final W3CEndpointReference endpoint = TestUtil.getCompletionCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier());

        CompletionCoordinatorClient.getClient().sendCommit(endpoint, addressingProperties, new InstanceIdentifier("sender")) ;
        . . .

Class CompletionCoordinatorClient {
    . . .
    public void sendCommit(final W3CEndpointReference endpoint, final AddressingProperties addressingProperties, final InstanceIdentifier identifier)
        throws SoapFault, IOException
    {
        EndpointReference initiator = getCompletionInitiator(endpoint);
        AddressingHelper.installFromFaultTo(addressingProperties, initiator, identifier);
        CompletionCoordinatorPortType port = getPort(endpoint, addressingProperties, commitAction);
        Notification commit = new Notification();

        port.commitOperation(commit);
    }

    private CompletionCoordinatorPortType getPort(final W3CEndpointReference endpoint,
                                                  final AddressingProperties addressingProperties,
                                                  final AttributedURI action)
    {
        AddressingHelper.installNoneReplyTo(addressingProperties);
        return WSATClient.getCompletionCoordinatorPort(endpoint, action, addressingProperties);
    }
    . . .

class AddressingHelper {
    . . .
    public static AddressingProperties createRequestContext(final String address, final String messageID)
    {
        AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
        final AddressingProperties requestProperties = builder.newAddressingProperties();
        requestProperties.setTo(makeURI(builder, address));
        if (messageID != null) {
            requestProperties.setMessageID(makeURI(builder, messageID));
        } else {
            // client does not care about id but we have to set some id or WSA will complain

            final String dummyID = MessageId.getMessageId();

            requestProperties.setMessageID(makeURI(builder, dummyID));
        }
        return requestProperties;
    }

    public static void installFromFaultTo(AddressingProperties addressingProperties, EndpointReference epReference, InstanceIdentifier identifier)
    {
        AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
        EndpointReference from = builder.newEndpointReference(epReference.getAddress().getURI());
        InstanceIdentifier.setEndpointInstanceIdentifier(from, identifier);
        addressingProperties.setFrom(from);
        EndpointReference faultTo = builder.newEndpointReference(epReference.getAddress().getURI());
        InstanceIdentifier.setEndpointInstanceIdentifier(faultTo, identifier);
        addressingProperties.setFaultTo(faultTo);
    }

    public static void installNoneReplyTo(AddressingProperties addressingProperties)
    {
        addressingProperties.setReplyTo(getNoneAddress());
    }

    private static EndpointReference noneAddress = null;

    private static synchronized EndpointReference getNoneAddress()
    {
        if (noneAddress == null) {
            AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
            AddressingConstants addressingConstants = builder.newAddressingConstants();
            try {
                URI noneURI = new URI(addressingConstants.getNoneURI());
                noneAddress = builder.newEndpointReference(noneURI);
            } catch (URISyntaxException e) {
                // will not happen
            }
        }

        return noneAddress;
    }

    public static javax.xml.ws.addressing.AttributedURI makeURI(AddressingBuilder builder, String messageID)
    {
        try {
            return builder.newURI(messageID);
        } catch (URISyntaxException use) {
            return null;
        }
    }
    . . .

class TestUtil {
    . . .
    public static W3CEndpointReference getCompletionCoordinatorEndpoint(String id)
    {
        return getEndpoint(AtomicTransactionConstants.COMPLETION_COORDINATOR_SERVICE_QNAME,
                AtomicTransactionConstants.COMPLETION_COORDINATOR_PORT_QNAME,
                completionCoordinatorServiceURI,
                id);
    }

    private static W3CEndpointReference getEndpoint(QName service, QName port, String address, String id)
    {
        try {
            W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
            builder.serviceName(service);
            builder.endpointName(port);
            builder.address(address);
            if (id != null) {
                InstanceIdentifier.setEndpointInstanceIdentifier(builder, id);
            }
            return builder.build();
        } catch (Exception e) {
            return null;
        }
    }
    . . .

class InstanceIdentifier {

    public static void setEndpointInstanceIdentifier(final W3CEndpointReferenceBuilder builder, final String identifier)
    {
        builder.referenceParameter(createInstanceIdentifierElement(identifier));
    }

    private static SOAPFactory factory = createSoapFactory();

    private static Name WSARJ_ELEMENT_INSTANCE_NAME;

    public static Element createInstanceIdentifierElement(final String instanceIdentifier)
    {
        try {
            SOAPElement element = factory.createElement(WSARJ_ELEMENT_INSTANCE_NAME);
            element.addNamespaceDeclaration(ArjunaConstants.WSARJ_PREFIX, ArjunaConstants.WSARJ_NAMESPACE);
            element.addTextNode(instanceIdentifier);
            return element;
        } catch (SOAPException se) {
            // TODO log error here (should never happen)
            return null;
        }
    }

    private static SOAPFactory createSoapFactory()
    {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            Name name = factory.createName(ArjunaConstants.WSARJ_ELEMENT_INSTANCE_IDENTIFIER,
                    ArjunaConstants.WSARJ_PREFIX,
                    ArjunaConstants.WSARJ_NAMESPACE);
            WSARJ_ELEMENT_INSTANCE_NAME = name;
            return factory;
        } catch (SOAPException e) {
            // TODO log error here (should never happen)
        }
        return null;
    }
    . . .
</pre>




> WSA client handler throws exception when installing reference parameters
> ------------------------------------------------------------------------
>
>                 Key: JBWS-2166
>                 URL: https://jira.jboss.org/jira/browse/JBWS-2166
>             Project: JBoss Web Services
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: jbossws-native
>    Affects Versions: jbossws-native-3.0.1
>            Reporter: Andrew Dinn
>            Assignee: Alessio Soldano
>             Fix For:  jbossws-native-3.1.1
>
>
> WSAddressingClientHandler.handleOutbound in package org.jboss.ws.extensions.addressing.jaxws is throwing the following exception when inserting reference parameters into a reply:
> 10:52:44,104 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
> javax.xml.ws.WebServiceException: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
> 	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.processHandlerFailure(HandlerChainExecutor.java:276)
> 	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:155)
> 	at org.jboss.ws.core.jaxws.client.ClientImpl.callRequestHandlerChain(ClientImpl.java:191)
> 	at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:298)
> 	at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:302)
> 	at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:172)
> 	at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:152)
> 	at $Proxy93.soapFault(Unknown Source)
> 	at com.arjuna.webservices11.wsaddr.client.SoapFaultClient.sendSoapFault(SoapFaultClient.java:72)
> 	at com.arjuna.webservices11.wsat.client.ParticipantClient.sendSoapFault(ParticipantClient.java:150)
> 	at com.arjuna.wst11.messaging.CoordinatorProcessorImpl.sendInvalidState(CoordinatorProcessorImpl.java:272)
> 	at com.arjuna.wst11.messaging.CoordinatorProcessorImpl.prepared(CoordinatorProcessorImpl.java:176)
> 	at com.arjuna.webservices11.wsat.sei.CoordinatorPortTypeImpl$1.executeTask(CoordinatorPortTypeImpl.java:61)
> 	at com.arjuna.services.framework.task.TaskWorker.run(TaskWorker.java:65)
> 	at java.lang.Thread.run(Thread.java:595)
> Caused by: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
> 	at org.apache.xerces.dom.ParentNode.internalInsertBefore(Unknown Source)
> 	at org.apache.xerces.dom.ParentNode.insertBefore(Unknown Source)
> 	at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
> 	at org.jboss.ws.core.soap.NodeImpl.appendChild(NodeImpl.java:477)
> 	at org.jboss.ws.core.soap.SOAPHeaderImpl.appendChild(SOAPHeaderImpl.java:198)
> 	at org.jboss.ws.core.soap.SOAPElementImpl.addChildElement(SOAPElementImpl.java:274)
> 	at org.jboss.ws.core.soap.SOAPHeaderImpl.addChildElement(SOAPHeaderImpl.java:70)
> 	at org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl.appendElement(SOAPAddressingPropertiesImpl.java:374)
> 	at org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl.appendElements(SOAPAddressingPropertiesImpl.java:352)
> 	at org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl.writeHeaders(SOAPAddressingPropertiesImpl.java:306)
> 	at org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler.handleOutbound(WSAddressingClientHandler.java:113)
> 	at org.jboss.ws.core.jaxws.handler.GenericHandler.handleMessage(GenericHandler.java:55)
> 	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:295)
> 	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:140)
> 	... 13 more
> The situation which manifests this problem is as follows:
> Client A attaches WS AddressingProperties to a port for server B, It installs a ReplyTo epr whose address identifies server A. It attaches a reference parameter wsarj:identifier to the epr. Client A then invokes service B.
> The implementation method of service B retrieves the request AddressingProperties from its message context and sets up a reply AddressingProperties instance by calling AddressingProperties.initializeAsReply. It obtains a port for service A, installs the reply properties on the port then invokes service A. The client handler under this invocation gets the error.
> The problem is that the SOAP implementation does not copy the reference parameter Element instance when it tries to insert them into the outgoing message. intiializeAsReply retrieves these elements from the incoming context ReplyTo/FaultTo and adds them to the element extension list of the reply addressing context. The client handler calls SOAPAddressingHandlerImpl.writeHeaders to add these elements as headers in the outbound message. writeHeaders eventually calls SOAPHeaderImpl.addChildElement to add each reference parameter Element to the outgoing message header.  addChildElement tests whether the Element is a SOAP element and, if so, assumes that it can be inserted directly into the outgoing message by calling appendElement. Unfortunately, the incoming reference parameters are associated with a dom node whose document is non-null and this barfs,claiming that someone is attempting a switcheroo on the document.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jbossws-issues mailing list