2

使用 SoapUI 发送请求时出现“无法创建安全的 XMLInputFactory”错误,我尝试了一些 stackoverflow 提到的解决方案,例如添加 woodstox 和 stax2-api,但问题仍然存在

来自 build.gradle:

compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
compile 'org.codehaus.woodstox:stax2-api:4.0.0'

compile 'org.apache.cxf:cxf-rt-frontend-jaxws:3.1.12'
compile 'org.apache.cxf:cxf-rt-ws-security:3.1.12'
compile 'org.apache.cxf:cxf-rt-transports-http:3.1.12'

它以前与woodstox-core一起工作,但开始抛出错误

compile 'com.fasterxml.woodstox:woodstox-core:5.0.3'

从版本 3 CXF 的先前解决方案中,甚至不需要woodstox,我也尝试过不使用woodstox。

是否可以像axis2一样更新任何其他依赖项?我的下一步应该是什么?谢谢

注意:使用tomcat 8.5.19

4

2 回答 2

3

所以找到了解决方案,正如有人提到的那样,在 SaxUtils.java 有一个

factory = XMLInputFactory.newInstance();

从哪里我们可以看到它的加载位置。

实际上,axis2 中存在冲突,因此通过排除 neethi

compile('org.apache.axis2:axis2-transport-http:1.5.1') {
    exclude group: 'javax.servlet', module: 'servlet-api'
    exclude module: 'XmlSchema'
    exclude group: 'org.apache.neethi', module: 'neethi'
    exclude group: 'org.codehaus.woodstox'
}
runtime ('org.apache.axis2:axis2-transport-local:1.5.1'){
    exclude group: 'org.codehaus.woodstox', module: 'wstx-asl'
}

冲突消失了。

于 2017-08-01T11:44:42.477 回答
1

我想与 'dotmindlabs' 确认关于 Axis2 的问题。在实现 Apache CXF 3.2.1 时,我还使用了 Axis2 的一些包。我遇到了同样的问题“无法创建安全的 XMLInputFactory”

该问题与 Axis2 Implements 的附加库严格有关。

我在下面提供了解决此问题所需的依赖项(Maven)更改。

  <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-transport-http -->
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-http</artifactId>
        <version>1.6.2</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.ws.commons.schema</groupId>
                <artifactId>XmlSchema</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.neethi</groupId>
                <artifactId>neethi</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.codehaus.woodstox</groupId>
                <artifactId>wstx-asl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

我希望这对将来遇到此问题的人有所帮助。

于 2018-01-29T11:35:41.103 回答