2 Replies Latest reply on Mar 14, 2011 7:54 AM by karthik rks

    WRONG_DOCUMENT_ERR in load test

    karthik rks Newbie

       

      I'm facing an issue while executing the load test on a ESB service 

      While testing for single thread instance on  JBOSS 5.0.2 & open JDK 1.6 everything works fine.

      But while performing load test for 20 threads following errors appears in the logs for all the requests.

       

       

      ERROR [SendSmsImpl] org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
      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:484)
                  at org.jboss.ws.core.soap.SOAPContentElement.appendChild(SOAPContentElement.java:440)
                  at org.jboss.ws.core.soap.SOAPElementImpl.addChildElement(SOAPElementImpl.java:273)
                  at org.jboss.ws.core.soap.SOAPContentElement.addChildElement(SOAPContentElement.java:188)
                  at org.jboss.ws.core.soap.XMLContent.expandContainerChildren(XMLContent.java:341)
                  at org.jboss.ws.core.soap.XMLContent.transitionTo(XMLContent.java:105)
                  at org.jboss.ws.core.soap.SOAPContentElement.transitionTo(SOAPContentElement.java:140)
                  at org.jboss.ws.core.soap.SOAPContentElement.expandToDOM(SOAPContentElement.java:502)
                  at org.jboss.ws.core.soap.SOAPContentElement.getChildNodes(SOAPContentElement.java:453)
      

       

       

      the same ESB works fine in JBoss 4.3 environment.

       

      To resolve above issue in JBOss 5.0.2 with open JDK 1.6 , as per suggestion mentioned in the below URL

      https://issues.jboss.org/browse/JBWS-3095

       

       

      We cloned the SOAP Message object in the listener.

       

          private SOAPMessage convertSoapMessage(SOAPMessage soapMessage)
                  throws SOAPException
          {
              String tempSoapMessage = getSoapMessageAsString(soapMessage);
              javax.xml.soap.MessageFactory msgFactory = javax.xml.soap.MessageFactory
                      .newInstance();
              SOAPMessage soapmessage = msgFactory.createMessage();
              SOAPPart soapPart = soapMessage.getSOAPPart();
              logger.info("String constructed from SOAP Message " + tempSoapMessage);
              if (tempSoapMessage != null)
              {
                  byte[] buffer = tempSoapMessage.getBytes();
                  ByteArrayInputStream stream = new ByteArrayInputStream(buffer);
                  StreamSource source = new StreamSource(stream);
                  soapPart.setContent(source);
                  try
                  {
                      logger.info(" SOAP Message Constructed from String  = > ");
                      soapmessage.writeTo(System.out);
                  }
                  catch (IOException e)
                  {
      ….
                  }
              }
              else
              {
      …
              }
              return soapmessage;
          }
      
      
       private String getSoapMessageAsString(SOAPMessage soapMessage)
          {
      
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              String encoding = "utf-8";
              String soapRequest = null;
      
              try
              {
                  if (soapMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING) != null)
                  {
                      encoding = soapMessage.getProperty(
                              SOAPMessage.CHARACTER_SET_ENCODING).toString();
                      soapMessage.writeTo(baos);
                  }
              }
              catch (SOAPException e1)
              {
                  e1.printStackTrace();
              }
              catch (IOException e1)
              {
                  e1.printStackTrace();
              }
      
              try
              {
                  soapRequest = baos.toString(encoding);
              }
              catch (Exception e)
              {
                  e.printStackTrace();
              }
              return soapRequest;
          }
      
      

      Below is the error occurred, while permforming load test for 20 threads (error while writing into stream)

       

       at org.jboss.ws.core.soap.SOAPElementImpl.writeElementContent(SOAPElementImpl.java:883)
              at org.jboss.ws.core.soap.SOAPElementImpl.writeElement(SOAPElementImpl.java:868)
              at org.jboss.ws.core.soap.SOAPElementImpl.writeElementContent(SOAPElementImpl.java:883)
              at org.jboss.ws.core.soap.SOAPElementImpl.writeElement(SOAPElementImpl.java:868)
              at org.jboss.ws.core.soap.SOAPElementWriter.writeElementInternal(SOAPElementWriter.java:147)
              at org.jboss.ws.core.soap.SOAPElementWriter.writeElement(SOAPElementWriter.java:128)
              at org.jboss.ws.core.soap.SOAPMessageImpl.writeTo(SOAPMessageImpl.java:353)
              at com.test.util.getSoapMessageAsString(Unknown Source)
              at com.test.util.convertSoapMessage(Unknown Source)
              at com.test.util.getMessageHeader(Unknown Source)
              at com.test.listeners.testImpl.getData(testListImpl.java:140)
              at sun.reflect.GeneratedMethodAccessor507.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerJSE.invoke(InvocationHandlerJSE.java:108)
      

       

       

      Please help us to resolve the same

       

      Regards

       

      Karthik

        • 1. WRONG_DOCUMENT_ERR in load test
          Tom Cunningham Master

          What's the second error?    You pasted in a stack locations but I don't see the actual error.

          • 2. WRONG_DOCUMENT_ERR in load test
            karthik rks Newbie

            java.lang.IllegalArgumentException: type: -1
                     at org.apache.xerces.dom.DeferredDocumentImpl.getNodeObject(Unknown Source)
                     at org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(Unknown Source)
                     at org.apache.xerces.dom.DeferredElementNSImpl.synchronizeChildren(Unknown Source)
                     at org.apache.xerces.dom.ParentNode.getChildNodes(Unknown Source)
                     at org.jboss.wsf.common.DOMWriter.printInternal(DOMWriter.java:261)
                     at org.jboss.wsf.common.DOMWriter.print(DOMWriter.java:233)
                     at org.jboss.ws.core.soap.XMLFragment.writeSourceInternal(XMLFragment.java:169)
                     at org.jboss.ws.core.soap.XMLFragment.writeTo(XMLFragment.java:146)
                     at org.jboss.ws.core.soap.SOAPContentElement.writeElement(SOAPContentElement.java:555)
                     at org.jboss.ws.core.soap.SOAPElementImpl.writeElementContent(SOAPElementImpl.java:883)
                     at org.jboss.ws.core.soap.SOAPElementImpl.writeElement(SOAPElementImpl.java:868)
                     at org.jboss.ws.core.soap.SOAPElementImpl.writeElementContent(SOAPElementImpl.java:883)
                     at org.jboss.ws.core.soap.SOAPElementImpl.writeElement(SOAPElementImpl.java:868)
                     at org.jboss.ws.core.soap.SOAPElementWriter.writeElementInternal(SOAPElementWriter.java:147)
                     at org.jboss.ws.core.soap.SOAPElementWriter.writeElement(SOAPElementWriter.java:128)
                     at org.jboss.ws.core.soap.SOAPMessageImpl.writeTo(SOAPMessageImpl.java:353)