【问题标题】:SAXNotRecognizedException: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' not recognizedSAXNotRecognizedException:无法识别功能“http://javax.xml.XMLConstants/feature/secure-processing”
【发布时间】:2015-11-22 13:37:20
【问题描述】:

我在解组类时收到此错误。我正在使用 Amazon 的 mTurks 以及 Spring、Maven 和(惊讶、惊讶)一个 xerces 问题已经引起了它的注意。

我以多种不同的方式使用 POM 来尝试解决问题,但我似乎无法找到解决方案。

我正在使用此处找到的 mturks 的 mavenized 版本: https://github.com/tc/java-aws-mturk

我已经明确地从 mturks 中排除了 xerces 的东西:

<dependency>
    <groupId>com.amazon</groupId>
    <artifactId>java-aws-mturk</artifactId>
    <version>1.2.2</version>
    <exclusions>
        <exclusion>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </exclusion>
        <exclusion>
            <groupId>apache-xerces</groupId>
            <artifactId>xercesImpl</artifactId>
        </exclusion>
        <exclusion>
            <groupId>apache-xerces</groupId>
            <artifactId>resolver</artifactId>
        </exclusion>
        <exclusion>
            <groupId>apache-xerces</groupId>
            <artifactId>xml-apis</artifactId>
        </exclusion>
    </exclusions>
</dependency>

并明确包含 xerces-impl 和 xml-api 依赖项:

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.11.0</version>
</dependency>
<dependency>
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.4.01</version>
</dependency>

我已经尝试了 xercesImpl 版本 2.9.1、2.11.0 和 xml-apis 版本 1.4.01、2.0.2 的所有四种组合,但无济于事。

xercesImpl 2.11.0 和 xml-api 2.0.2 导致不同的错误:

java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

我该如何解决这个问题?

【问题讨论】:

    标签: java xml spring maven xerces


    【解决方案1】:

    这不是特定于 mturks,但这是在 eclipse 中查找 xerces 冲突以解决问题的一般方法。

    1. 在 eclipse 编辑器中打开你的 pom.xml 并切换到“Dependency Hierarchy”选项卡

    2. 在右上角的“过滤器”框中,输入“xerces”

    3. 引入 xercesImpl 的依赖项将显示在左侧的“依赖关系层次结构”窗格中

    4. 右键单击有问题的 xercesImpl 条目并选择“排除 Maven Artifact...”。这将使用排除冲突来更新您的 pom,从而解决冲突

    5. 请务必按 ctrl-s 保存您的 pom 更改

    以下是原始 pom.xml 中的 before 和 after 示例(eclipse 在上述步骤中为您完成了此操作:

    之前

        <dependency>
          <groupId>junit-addons</groupId>
          <artifactId>junit-addons</artifactId>
          <version>1.4</version>
          <scope>test</scope>
        </dependency>
    

    之后

        <dependency>
          <groupId>junit-addons</groupId>
          <artifactId>junit-addons</artifactId>
          <version>1.4</version>
          <scope>test</scope>
          <exclusions>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
          </exclusions>
        </dependency>
    

    通过这个简单的更改,您可以避免“由于设置限制而不允许访问...”错误,而无需诉诸 JRE 修改或全局设置

    【讨论】:

      【解决方案2】:

      我无法找到让 mturks 1.2.2 正常工作的方法。但是,使用不同的版本(1.6.2)解决了这个问题。

      我更新后的 pom 现在看起来像这样:

      <repository>
          <id>clojars.org</id>
          <url>http://clojars.org/repo</url>
      </repository>
      ...
      <dependency>
          <groupId>org.clojars.zaxtax</groupId>
          <artifactId>java-aws-mturk</artifactId>
          <version>1.6.2</version>
          <exclusions>
              <exclusion>
                  <groupId>commons-lang</groupId>
                  <artifactId>commons-lang</artifactId>
              </exclusion>
          </exclusions>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-11-04
        • 1970-01-01
        • 2012-08-07
        • 2021-01-06
        • 1970-01-01
        • 2021-01-22
        • 2019-08-01
        相关资源
        最近更新 更多