CXFServlet throws java.lang.NoSuchMethodError: org.codehaus.stax2.ri.EmptyIterator.getInstance()Lorg/codehaus/stax2/ri/EmptyIterator;

JuanMoreno picture JuanMoreno · Dec 31, 2018 · Viewed 9.6k times · Source

I'm using Java 11, Spring Boot 2.1.1 and Apache CXF 3.2.7 to expose a SOAP web service that imports an XSD schema. In the WSDL it shows like:

<wsdl:import location="http://localhost:9000/endpoint/ws?wsdl=WS_endpointSoapPort.wsdl" namespace="http://test.com"> </wsdl:import>

When I send a query it fails with the following stack:

2018-12-31 12:05:54,908 ERROR se.[Tomcat].[localhost].[/].[CXFServlet]: 175 - Servlet.service() for servlet [CXFServlet] in context with path [] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoSuchMethodError: org.codehaus.stax2.ri.EmptyIterator.getInstance()Lorg/codehaus/stax2/ri/EmptyIterator;

Any thoughts?

Answer

Julien Kronegg picture Julien Kronegg · Sep 8, 2019

I had a conflict on the org.codehaus.woodstox:stax2-api which was included in version 3.1.4 within org.apache.cxf:cxf-core and in version 4.1 within com.sun.xml.ws:rt. I solved the conflict by removing the library using Maven excludes:

        <exclusions>
            <exclusion>
                <groupId>org.codehaus.woodstox</groupId>
                <artifactId>stax2-api</artifactId><!-- 4.1 conflicts with 3.1.4 from apache cxf-spring-boot-starter-jaxws-->
            </exclusion>
        </exclusions>