[JBoss JIRA] (JBESB-3730) BaseWebService: DOMException: WRONG_DOCUMENT_ERR when when running with JBoss AS 6.1.0.GA
by Daniel Bevenius (JIRA)
Daniel Bevenius created JBESB-3730:
--------------------------------------
Summary: BaseWebService: DOMException: WRONG_DOCUMENT_ERR when when running with JBoss AS 6.1.0.GA
Key: JBESB-3730
URL: https://issues.jboss.org/browse/JBESB-3730
Project: JBoss ESB
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: Web Services
Affects Versions: 4.10
Environment: JBoss AS 6.1.0.GA
JBoss ESB 4.10
Mac OS X/Linux
Reporter: Daniel Bevenius
When running on JBoss AS 6.1.0.GA the following exception was logged with a warn log level:
{noformat}
14:16:10,140 WARN [org.jboss.internal.soa.esb.webservice.BaseWebService] Failed to parse fault detail: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:352) [:1.6.0_29]
at com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:284) [:1.6.0_29]
at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(NodeImpl.java:235) [:1.6.0_29]
at org.jboss.internal.soa.esb.webservice.BaseWebService.invoke(BaseWebService.java:243) [:]
at org.jboss.internal.soa.esb.webservice.BaseWebService.invoke(BaseWebService.java:88) [:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_29]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_29]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_29]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_29]
at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:102) [:1.4.1.SP1]
at org.jboss.wsf.stack.cxf.AbstractInvoker._invokeInternal(AbstractInvoker.java:164) [:3.4.1.GA]
at org.jboss.wsf.stack.cxf.AbstractInvoker.invoke(AbstractInvoker.java:112) [:3.4.1.GA]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [:2.3.1-patch-01]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_29]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_29]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_29]
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [:2.3.1-patch-01]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106) [:2.3.1-patch-01]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255) [:2.3.1-patch-01]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113) [:2.3.1-patch-01]
at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:97) [:2.3.1-patch-01]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:461) [:2.3.1-patch-01]
at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:172) [:3.4.1.GA]
at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:57) [:3.4.1.GA]
at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:156) [:3.4.1.GA]
at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:90) [:3.4.1.GA]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) [:2.3.1-patch-01]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103) [:2.3.1-patch-01]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [:1.0.0.Final]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) [:2.3.1-patch-01]
{noformat}
The offending code in BaseWebService:
{code}
final Body body = faultMessage.getBody() ;
final QName faultCode = (QName)body.get(Fault.DETAIL_CODE_CONTENT) ;
final String faultDescription = (String)body.get(Fault.DETAIL_DESCRIPTION_CONTENT) ;
final String faultDetail = (String)body.get(Fault.DETAIL_DETAIL_CONTENT) ;
if (faultCode != null)
{
faultMsg = SOAP_MESSAGE_FACTORY.createMessage() ;
final SOAPFault fault = faultMsg.getSOAPBody().addFault(faultCode, faultDescription) ;
if (faultDetail != null)
{
try
{
final Document detailDoc = parseAsDom(faultDetail) ;
final Detail detail = fault.addDetail() ;
detail.appendChild(detailDoc.getDocumentElement()) ;
}
catch (final Exception ex2)
{
LOGGER.warn("Failed to parse fault detail", ex2) ;
}
}
}
{code}
The code first creating a SoapMessage using the SOAP_MESSAGE_FACTORY and later one is created from the parseAsDom method. The latter is then added to the first
which is the cause of this exception. The DOM spec contains the following about this:
??The DOM Recommendation specifies that appendChild Must throw DOMException (WRONG_DOCUMENT_ERR) if an attempt is made to insert a node from one ownerDocument into a tree with a different ownerDocument.??
Modifying the above method and changing the appendChild call to the following:
{code}
detail.appendChild(detail.getOwnerDocument().importNode(detailDoc.getDocumentElement(), true)) ;
{code}
Please see attached unit test which reproduces this issue.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira