Object of type ElementNSImpl coming as com.sun.org.apache.xerces.internal.dom.ElementNSImpl

5.1k Views Asked by At

So my WS-Trust server deployed on JDK1.8.0_161 environment is expecting a request which will contain xml nodes of type org.apache.xerces.dom.ElementNSImpl, but when the request comes, the nodes are of type com.sun.org.apache.xerces.internal.dom.ElementNSImpl, which is not making me not read the data from request. I am using xerces:xercesImpl:2.11.0 library, but wondering if JDK is messing up with the request parsing on server end. Currently I only see rt.jar that contains com.sun.org.apache.xerces.internal.dom.ElementNSImpl. What am I missing? Have anyone seen this error?

1

There are 1 best solutions below

0
yogsma On BEST ANSWER

I solved this problem by using Element as interface rather than using implementation ElementNSImpl. This will make the implementation environment independent.

So the code looks like this

if(object instanceof org.w3c.dom.Element)

instead of

if(object instanceof ElementNSImpl)