【问题标题】:CXF 3.1.12 Cannot create a secure XMLInputFactoryCXF 3.1.12 无法创建安全的 XMLInputFactory
【发布时间】:2017-08-01 07:37:21
【问题描述】:

使用 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

【问题讨论】:

    标签: java cxf build.gradle woodstox


    【解决方案1】:

    所以找到了解决方案,正如有人提到的那样,在 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'
    }
    

    冲突消失了。

    【讨论】:

      【解决方案2】:

      我想与 '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>
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-12-05
        • 2014-09-18
        • 1970-01-01
        • 1970-01-01
        • 2018-12-24
        • 2014-03-05
        • 1970-01-01
        相关资源
        最近更新 更多