2

我正在尝试在 Weblogic 12c 中部署 Web 应用程序(.war 格式)。当我尝试部署它时,Weblogic 抛出以下错误:

java.lang.ClassCastException: weblogic.xml.jaxp.RegistryXMLInputFactory cannot be cast to javax.xml.stream.XMLInputFactory
Error weblogic.xml.jaxp.RegistryXMLInputFactory cannot be cast to javax.xml.stream.XMLInputFactory

我已经阅读了太多关于这个错误的线程和“解决方案”,但没有一个对我有用。

这是我的 weblogic.xml:

<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
    <context-root>appName</context-root>
    <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
    <resource-description>
        <res-ref-name>jdbc/testdb</res-ref-name>
        <jndi-name>jdbc/testdb</jndi-name>
    </resource-description>
</weblogic-web-app>

这些是我在 pom.xml 中的依赖项:

    <spring.version>3.1.1.RELEASE</spring.version>
    <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-core</artifactId>  
        <version>${spring.version}</version>  
    </dependency> 
    <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-context</artifactId>  
        <version>${spring.version}</version>  
    </dependency>  
    <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-webmvc</artifactId>  
        <version>${spring.version}</version>  
    </dependency>  
    <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-orm</artifactId>  
        <version>${spring.version}</version>  
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ws.xmlschema</groupId>
        <artifactId>xmlschema-core</artifactId>
        <version>2.2.0</version>
    </dependency>

你能帮我解决这个问题吗?谢谢!

4

1 回答 1

3

我通过明确排除spring-ws-core传递的stax-api依赖项解决了这个问题。尝试以下操作:

<dependency>
  <groupId>org.springframework.ws</groupId>
  <artifactId>spring-ws-core</artifactId>
  <version>2.1.0.RELEASE</version>
  <exclusions>
    <exclusion>
      <groupId>javax.xml.stream</groupId>
      <artifactId>stax-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>

然后,您只需确保在使用应用程序时没有其他 XML 解析问题。

HTH,本

于 2015-07-22T12:00:36.637 回答