NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces

Viewed 54759

Trying to retrieve the SOAP body from a SOAP response, but getting this error:

NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

Document doc = soapResMsg.getSOAPBody().extractContentAsDocument(); -- Exception is thrown here
org.dom4j.io.DOMReader d4Reader = new org.dom4j.io.DOMReader();
org.dom4j.Document d4doc = d4Reader.read(doc);

Using Saaj1.4

What would be a fix for this?

6 Answers

I encountered the issue with Java 8 and WebLogic 12c.

In my case, it helped to add to WAR org.glassfish.jaxb:jaxb-runtime:2.3.3

The tricky thing was that the application worked without the dependency pretty long time. But something in one particular request caused this error and I am still not sure what it was. However, the new dependency helped.

Related