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

时间:2018-12-31 17:59:42

标签: java web-services soap cxf stax

我正在使用Java 11,Spring Boot 2.1.1和Apache CXF 3.2.7来公开导入XSD模式的SOAP Web服务。在WSDL中,它显示为:

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

当我发送查询时,它失败并显示以下堆栈:

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;

有什么想法吗?

5 个答案:

答案 0 :(得分:2)

我在org.codehaus.woodstox:stax2-api的3.1.4版和org.apache.cxf:cxf-core的4.1版中所包含的com.sun.xml.ws:rt发生了冲突。我通过使用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>

答案 1 :(得分:0)

经过深入研究,我发现以下JIRA提到了Stax2版本的问题。顺便说一句,票证说它可以解决我所使用的版本。

最后,我修复了升级到woodstox-core-5.2.0的问题。实际上,该库提到了在该版本中解决的类似问题。详细信息here

我当前的mvn dependency:tree是:

[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

答案 2 :(得分:0)

我遇到了同样的问题,并升级到CXF 3.2.7或更高版本为我解决了该问题。

答案 3 :(得分:0)

我在Maven中的某些依赖项存在相同的问题,该依赖项将 stax2-api 与不同版本一起使用。

Maven编译器仅使用stax2-api的一个版本(在我的情况下,它是最新版本),因此我尝试使用运行时包含3.1.4和4.2.1版本(其他jar需要此版本)。范围

这是pom.xml的片段

<dependency>
  <groupId>org.codehaus.woodstox</groupId>
  <artifactId>stax2-api</artifactId>
  <version>4.2.1</version>
  <scope>runtime</scope>
</dependency>
     
<dependency>
  <groupId>org.codehaus.woodstox</groupId>
  <artifactId>stax2-api</artifactId>
  <version>3.1.4</version>
  <scope>runtime</scope>
</dependency>

备注:对于我来说,当以 java应用程序的形式执行类时可以使用,但是在 web应用程序中的执行时不能使用环境(Tomcat)!

答案 4 :(得分:0)

密钥可能在您的 mvn:dependency-tree 输出中。就我而言:

[INFO]    \- org.apache.cxf:cxf-rt-ws-security:jar:3.3.6:compile
[INFO]       +- org.apache.cxf:cxf-core:jar:3.3.6:compile
[INFO]       |  \- com.fasterxml.woodstox:woodstox-core:jar:5.3.0:compile (version managed from 5.0.3)
[INFO]       |     \- org.codehaus.woodstox:stax2-api:jar:4.2:compile
[INFO]       \- org.apache.wss4j:wss4j-policy:jar:2.2.5:compile
[INFO]          \- org.apache.neethi:neethi:jar:3.1.1:compile
[INFO]             \- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
[INFO]                \- (org.codehaus.woodstox:stax2-api:jar:3.1.4:compile - omitted for conflict with 4.2)

org.apache.cxf:cxf-rt-ws-security:jar:3.3.6 导致 stax2-api 的 3.1.4 版和 4.2 版,因为 woodstox-core-asl 依赖项非常过时(从 2014 年开始)。我将不得不看看我是否可以摆脱它,因为它会导致上述 NoSuchMethodFoundError。