[SOLVED] org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR:

Here you can find the solution for a problem: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR exception

The problem

When you invoke a web service you got the exception like below:

org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

The cause

There is a bug in the wss4j-ws-security-dom library in version 2.2.0 which might be delivered as dependency by SpringBoot freamework.

The solution

As as solution you can override the wss4j-ws-security-dom library dependency to higher version for the time it will be included in proper vesion as SpringBoot dependency. For do this – just open pom.xml file and add the following dependency.

<dependency>
    <groupId>org.apache.wss4j</groupId>
    <artifactId>wss4j-ws-security-dom</artifactId>
    <version>2.2.2</version>
</dependency>

6
Leave a Reply

avatar
4 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
5 Comment authors
Hemadri MedidaSrinivas HNlukasz.cieslaTimothy ShouldiceTomas Flekac Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Tomas Flekac
Guest
Tomas Flekac

Hello,

with your solutin i came with error org.apache.xml.security.utils.XMLUtils.encodeToString([B)Ljava/lang/String;

For me was solution to downgrade saaj lib to 1.3:

com.sun.xml.messaging.saaj
saaj-impl
1.3

Do you know when we can expect fix?

Thanks

Timothy Shouldice
Guest
Timothy Shouldice

Thanks for posting this, I hit the same issue and your solution got me back up running.

Srinivas HN
Guest
Srinivas HN

Hello,

It solved my problem too thanks much for the solution. Do you know for which version of spring boot version is this happening and from when ? It was working for me last week and suddenly started throwing this error. It would be helpful for me to get an answer.

Hemadri Medida
Guest
Hemadri Medida

Thank you very much, the above solution helped me solve the problem quickly.

Close Menu