javaweb-servicessoapcxfstax

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


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?


Solution

  • After research in deeply, I found the following JIRA that mentions a problem with Stax2 version. BTW the ticket said that it resolves with the version that I'm using.

    In the end, I fixed upgrading to woodstox-core-5.2.0. In fact, the library mentions a similar problem that was solved in that version. Details here.

    My current mvn dependency:tree is:

    [INFO] +- org.springframework.boot:spring-boot-starter:jar:2.1.1.RELEASE:compile
    [INFO] |  +- org.springframework.boot:spring-boot:jar:2.1.1.RELEASE:compile
    [INFO] |  |  \- org.springframework:spring-context:jar:5.1.3.RELEASE:compile
    [INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.1.RELEASE:compile
    [INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
    [INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
    [INFO] |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile
    [INFO] |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.11.1:compile
    [INFO] |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
    [INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
    [INFO] |  +- org.springframework:spring-core:jar:5.1.3.RELEASE:compile
    [INFO] |  |  \- org.springframework:spring-jcl:jar:5.1.3.RELEASE:compile
    [INFO] |  \- org.yaml:snakeyaml:jar:1.23:runtime
    [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.1.RELEASE:compile
    [INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.1.1.RELEASE:compile
    [INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.7:compile
    [INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
    [INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.7:compile
    [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.7:compile
    [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.7:compile
    [INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.7:compile
    [INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.1.RELEASE:compile
    [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.13:compile
    [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.13:compile
    [INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.13:compile
    [INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.13.Final:compile
    [INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
    [INFO] |  |  \- com.fasterxml:classmate:jar:1.4.0:compile
    [INFO] |  +- org.springframework:spring-web:jar:5.1.3.RELEASE:compile
    [INFO] |  |  \- org.springframework:spring-beans:jar:5.1.3.RELEASE:compile
    [INFO] |  \- org.springframework:spring-webmvc:jar:5.1.3.RELEASE:compile
    [INFO] |     +- org.springframework:spring-aop:jar:5.1.3.RELEASE:compile
    [INFO] |     \- org.springframework:spring-expression:jar:5.1.3.RELEASE:compile
    [INFO] +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.1.RELEASE:compile
    [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.1.RELEASE:test
    [INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.1.1.RELEASE:test
    [INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.1.RELEASE:test
    [INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
    [INFO] |  |  \- net.minidev:json-smart:jar:2.3:test
    [INFO] |  |     \- net.minidev:accessors-smart:jar:1.2:test
    [INFO] |  +- junit:junit:jar:4.12:test
    [INFO] |  +- org.assertj:assertj-core:jar:3.11.1:test
    [INFO] |  +- org.mockito:mockito-core:jar:2.23.4:test
    [INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.9.5:test
    [INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.9.5:test
    [INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
    [INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
    [INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
    [INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
    [INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
    [INFO] |  +- org.springframework:spring-test:jar:5.1.3.RELEASE:test
    [INFO] |  \- org.xmlunit:xmlunit-core:jar:2.6.2:test
    [INFO] +- org.apache.cxf:cxf-spring-boot-starter-jaxws:jar:3.2.7:compile
    [INFO] |  +- org.apache.cxf:cxf-spring-boot-autoconfigure:jar:3.2.7:compile
    [INFO] |  +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:3.2.7:compile
    [INFO] |  |  +- xml-resolver:xml-resolver:jar:1.2:compile
    [INFO] |  |  +- org.ow2.asm:asm:jar:6.2:compile
    [INFO] |  |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:3.2.7:compile
    [INFO] |  |  +- org.apache.cxf:cxf-rt-frontend-simple:jar:3.2.7:compile
    [INFO] |  |  \- org.apache.cxf:cxf-rt-ws-addr:jar:3.2.7:compile
    [INFO] |  |     \- org.apache.cxf:cxf-rt-ws-policy:jar:3.2.7:compile
    [INFO] |  \- javax.validation:validation-api:jar:2.0.1.Final:compile
    [INFO] +- com.fasterxml.woodstox:woodstox-core:jar:5.2.0:compile
    [INFO] |  \- org.codehaus.woodstox:stax2-api:jar:4.1:compile
    [INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:3.2.7:compile
    [INFO] |  \- org.apache.cxf:cxf-core:jar:3.2.7:compile
    [INFO] |     \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.3:compile
    [INFO] +- org.apache.cxf:cxf-rt-ws-security:jar:3.2.7:compile
    [INFO] |  +- org.apache.cxf:cxf-rt-bindings-soap:jar:3.2.7:compile
    [INFO] |  |  +- org.apache.cxf:cxf-rt-wsdl:jar:3.2.7:compile
    [INFO] |  |  |  \- wsdl4j:wsdl4j:jar:1.6.3:compile
    [INFO] |  |  \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.2.7:compile
    [INFO] |  +- org.apache.cxf:cxf-rt-security-saml:jar:3.2.7:compile
    [INFO] |  |  \- org.apache.cxf:cxf-rt-security:jar:3.2.7:compile
    [INFO] |  +- net.sf.ehcache:ehcache:jar:2.10.6:compile
    [INFO] |  +- org.apache.wss4j:wss4j-ws-security-dom:jar:2.2.2:compile
    [INFO] |  |  \- org.apache.wss4j:wss4j-ws-security-common:jar:2.2.2:compile
    [INFO] |  |     +- org.apache.santuario:xmlsec:jar:2.1.2:compile
    [INFO] |  |     |  \- commons-codec:commons-codec:jar:1.11:compile
    [INFO] |  |     +- org.opensaml:opensaml-saml-impl:jar:3.3.0:compile
    [INFO] |  |     |  +- org.opensaml:opensaml-profile-api:jar:3.3.0:compile
    [INFO] |  |     |  |  \- org.opensaml:opensaml-core:jar:3.3.0:compile
    [INFO] |  |     |  |     \- io.dropwizard.metrics:metrics-core:jar:4.0.3:compile
    [INFO] |  |     |  +- org.opensaml:opensaml-saml-api:jar:3.3.0:compile
    [INFO] |  |     |  |  +- org.opensaml:opensaml-xmlsec-api:jar:3.3.0:compile
    [INFO] |  |     |  |  \- org.opensaml:opensaml-soap-api:jar:3.3.0:compile
    [INFO] |  |     |  +- org.opensaml:opensaml-security-impl:jar:3.3.0:compile
    [INFO] |  |     |  |  \- org.opensaml:opensaml-security-api:jar:3.3.0:compile
    [INFO] |  |     |  |     +- org.cryptacular:cryptacular:jar:1.1.1:compile
    [INFO] |  |     |  |     \- org.bouncycastle:bcprov-jdk15on:jar:1.54:compile
    [INFO] |  |     |  +- org.opensaml:opensaml-xmlsec-impl:jar:3.3.0:compile
    [INFO] |  |     |  \- net.shibboleth.utilities:java-support:jar:7.3.0:compile
    [INFO] |  |     |     +- com.google.guava:guava:jar:19.0:compile
    [INFO] |  |     |     \- joda-time:joda-time:jar:2.10.1:compile
    [INFO] |  |     +- org.opensaml:opensaml-xacml-impl:jar:3.3.0:compile
    [INFO] |  |     |  \- org.opensaml:opensaml-xacml-api:jar:3.3.0:compile
    [INFO] |  |     +- org.opensaml:opensaml-xacml-saml-impl:jar:3.3.0:compile
    [INFO] |  |     |  \- org.opensaml:opensaml-xacml-saml-api:jar:3.3.0:compile
    [INFO] |  |     +- org.jasypt:jasypt:jar:1.9.2:compile
    [INFO] |  |     \- org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:jar:1.8.4:compile
    [INFO] |  +- org.apache.wss4j:wss4j-policy:jar:2.2.2:compile
    [INFO] |  |  \- org.apache.neethi:neethi:jar:3.1.1:compile
    [INFO] |  |     \- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
    [INFO] |  |        \- javax.xml.stream:stax-api:jar:1.0-2:compile
    [INFO] |  +- org.apache.wss4j:wss4j-ws-security-stax:jar:2.2.2:compile
    [INFO] |  |  \- org.apache.wss4j:wss4j-bindings:jar:2.2.2:compile
    [INFO] |  \- org.apache.wss4j:wss4j-ws-security-policy-stax:jar:2.2.2:compile
    [INFO] +- org.apache.cxf:cxf-rt-features-logging:jar:3.2.7:compile
    [INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
    [INFO] +- org.apache.commons:commons-lang3:jar:3.8.1:compile
    [INFO] +- org.glassfish.jaxb:jaxb-runtime:jar:2.4.0-b180830.0438:compile
    [INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
    [INFO] |  +- org.glassfish.jaxb:txw2:jar:2.4.0-b180830.0438:compile
    [INFO] |  +- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
    [INFO] |  +- org.jvnet.staxex:stax-ex:jar:1.8:compile
    [INFO] |  +- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.15:compile
    [INFO] |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
    [INFO] +- com.sun.xml.ws:jaxws-rt:pom:2.3.1:compile
    [INFO] |  +- javax.xml.ws:jaxws-api:jar:2.3.1:compile
    [INFO] |  +- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
    [INFO] |  +- javax.jws:javax.jws-api:jar:1.1:compile
    [INFO] |  +- com.sun.xml.ws:policy:jar:2.7.5:compile
    [INFO] |  |  \- com.sun.activation:javax.activation:jar:1.2.0:compile
    [INFO] |  +- org.glassfish.gmbal:gmbal-api-only:jar:3.1.0-b001:compile
    [INFO] |  |  \- org.glassfish.external:management-api:jar:3.0.0-b012:compile
    [INFO] |  +- com.sun.xml.stream.buffer:streambuffer:jar:1.5.6:compile
    [INFO] |  +- org.jvnet.mimepull:mimepull:jar:1.9.10:compile
    [INFO] |  +- org.glassfish.ha:ha-api:jar:3.1.9:compile
    [INFO] |  \- com.sun.xml.messaging.saaj:saaj-impl:jar:1.5.0:compile
    [INFO] \- com.sun.xml.ws:rt:jar:2.3.1:compile