Skip to main content

JAX-WS: xmlstreamreaderexception unexpected xml tag

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-10-08


I try to run a JAX-WS Web Service. Therefore I created a Web Service from WSDL with NetBeans 7.3.1. If I run the Web Service I get this error:
Caused by: unexpected xml tag. expected {}, but found {}

I have nowhere in my entire project the string "" also not in the WSDL file. Then I tried to implement a SOAPHandler like this guy recommended:

I had to change the code otherwise I get:
Caused by: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPElement


Text textElement = (Text) soapBody.getFirstChild();
SOAPElement oldElement = textElement.getParentElement();

but I run into java.lang.StackOverflowError. Reason is the recursive method:

private void cloneToNewNamespace(Node nodeToRename, SOAPElement parentElement, String prefix) throws SOAPException {
        if (nodeToRename instanceof SOAPElement) {
            SOAPElement elementToRename = (SOAPElement) nodeToRename;
            SOAPElement newElement = parentElement.addChildElement(elementToRename.getElementName().getLocalName(), prefix);
            int tmp = elementToRename.getChildNodes().getLength();

            for (int index = 0; index < elementToRename.getChildNodes().getLength(); index++) {
                Node childNode = elementToRename.getChildNodes().item(index);
                cloneToNewNamespace(childNode, newElement, prefix);
        } else {

I also tried to intercept this issue by adding a, but there was no chance to change anything.

Another guy posted also this issue in this forum:
but I don't use or have sun-jaxws.xml. So this workaround doesn't work for me.

In this blog somebody gave the advice to annotate bidirectional objects with @Transient:
But I have no bidirectional mapping. So this is also not the solution.

My pom.xml looks like this:




I use the following versions:

JAX-WS: JAX-WS RI 2.2.7-b01
JDK: 1.7.25

Can somebody give me a hint to solve this issue?
(I also posted this question on StackOverflow, but didn't get an answer)