2017-03-01 375 views
5

我試圖解組XML數據輸入流時遇到此異常。這顯然是Xerces庫的一個問題,但我很難找出解決方案。我在帶有Java 8的Glassfish服務器上使用EclipseLink運行Java EE程序。在將XML輸入流作爲參數的REST服務中發生此錯誤。我得到的錯誤是:SAXNotRecognizedException雖然解組XML輸入流

Caused by: java.lang.IllegalStateException: org.xml.sax.SAXNotRecognizedException: unrecognized feature http://javax.xml.XMLConstants/feature/secure-processing 
at com.sun.xml.bind.v2.util.XmlFactory.createParserFactory(XmlFactory.java:135) 
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(UnmarshallerImpl.java:154) 
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:172) 
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:219) 

我已經看到張貼在這裏提示要升級我使用了Xerces庫,並擁有它是最上層的依賴關係,Maven的劫掠的其他問題,而不是一個某些其他圖書館,但它還沒有爲我工作。我的POM文件的相關部分是:

<dependencies> 
    <dependency> 
     <groupId>xerces</groupId> 
     <artifactId>xercesImpl</artifactId> 
     <version>2.11.0</version> 
    </dependency> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.glassfish.jersey.containers</groupId> 
     <artifactId>jersey-container-servlet</artifactId> 
     <version>2.22.2</version> 
     <scope>provided</scope> 
     <exclusions> 
      <exclusion> 
       <groupId>xerces</groupId> 
       <artifactId>xercesImpl</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>xerces</groupId> 
       <artifactId>xerces</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
     <version>4.0.2.GA</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.primefaces</groupId> 
     <artifactId>primefaces</artifactId> 
     <version>6.0</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>2.4</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-fileupload</groupId> 
     <artifactId>commons-fileupload</artifactId> 
     <version>1.3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.10</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.6</version> 
    </dependency> 
    <dependency> 
     <groupId>org.dom4j</groupId> 
     <artifactId>dom4j</artifactId> 
     <version>2.0.0-RC1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>19.0</version> 
    </dependency> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time</artifactId> 
     <version>2.9.2</version> 
    </dependency>  
    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi-ooxml</artifactId> 
     <version>3.14</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.xmlbeans</groupId> 
     <artifactId>xmlbeans</artifactId> 
     <version>2.6.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.commons</groupId> 
     <artifactId>commons-csv</artifactId> 
     <version>1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>org.eclipse.persistence.core</artifactId> 
     <version>2.5.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.0.6.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>3.0.6.RELEASE</version> 
    </dependency>  
    <dependency> 
     <groupId>org.passay</groupId> 
     <artifactId>passay</artifactId> 
     <version>1.2.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.openejb</groupId> 
     <artifactId>openejb-api</artifactId> 
     <version>4.7.4</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-core</artifactId> 
     <version>1.10.19</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>main.java.com.exavault</groupId> 
     <artifactId>evapi</artifactId> 
     <version>1.0.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.glassfish.jersey.security</groupId> 
     <artifactId>oauth1-client</artifactId> 
     <version>2.25</version> 
    </dependency> 
    <dependency> 
     <groupId>com.force.api</groupId> 
     <artifactId>force-wsc</artifactId> 
     <version>39.0.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.mindrot</groupId> 
     <artifactId>jbcrypt</artifactId> 
     <version>0.3m</version> 
    </dependency> 
</dependencies> 

我能想到的唯一的事情仍然造成的問題是,什麼是使用Xerces的庫還在,但我無法找到是依賴什麼使用它。另外,在使用xercesImpl 2.11.0之前,我最初一直使用xercesImpl版本2.0.2和xerces 2.0.2,儘管這似乎並沒有幫助擺脫這個錯誤。

+0

使用'MVN依賴性:樹-Dverbose -Dincludes = xercesImpl'我不是在你的依賴看到xercesImpl,它來自你的GlassFish服務器? – approxiblue

+0

我在輸出中沒有看到任何指向xerces jar的東西。我猜它必須來自Glassfish的某個庫,但是我沒有看到任何明顯的東西。 – gdawgrancid

回答