java.lang.ClassCastException:org.apache.xerces.jaxp.DocumentBuilderFactoryImpl无法强制转换为javax.xml.parsers.DocumentBuilderFactory [英] java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
问题描述
我正在使用 java1.6
, jboss5.1
和 Spring
maven 3.2.5
在我的项目中。我正在
java.lang.ClassCastException:org.apache.xerces.jaxp.DocumentBuilderFactoryImpl无法强制转换为javax.xml.parsers.DocumentBuilderFactory
这是我的Pom.xml
< project xmlns =http://maven.apache.org/POM/4.0.0 xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http:// maven.apache.org/maven-v4_0_0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> com.varun.batch< / groupId>
< artifactId> myproject< / artifactId>
< packaging> war< / packaging>
< version> 0.0.1-SNAPSHOT< / version>
< name> myproject Maven Webapp< / name>
< url> http://maven.apache.org< / url>
< dependencies>
<! - Spring ORM支持 - >
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-orm< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
<! - Spring Batch - >
< dependency>
< groupId> org.springframework.batch< / groupId>
< artifactId> spring-batch-core< / artifactId>
< version> 3.0.1.RELEASE< / version>
< / dependency>
< dependency>
< groupId> org.springframework.batch< / groupId>
< artifactId> spring-batch-infrastructure< / artifactId>
< version> 3.0.1.RELEASE< / version>
< / dependency>
< dependency>
< groupId> org.apache.axis2< / groupId>
< artifactId> axis2< / artifactId>
< version> 1.6.2< / version>
< / dependency>
<依赖>
< groupId> org.apache.xmlbeans< / groupId>
< artifactId> xmlbeans< / artifactId>
< version> 2.5.0< / version>
< / dependency>
<依赖>
< groupId> org.apache.axis2< / groupId>
< artifactId> axis2-transport-local< / artifactId>
< version> 1.6.1< / version>
< / dependency>
<依赖>
< groupId> org.apache.axis2< / groupId>
< artifactId> axis2-transport-http< / artifactId>
< version> 1.6.1< / version>
< / dependency>
<依赖>
< groupId> commons-codec< / groupId>
< artifactId> commons-codec< / artifactId>
< version> 1.6< / version>
< / dependency>
< dependency>
< groupId> org.apache.poi< / groupId>
< artifactId> poi< / artifactId>
< version> 3.9< / version>
< / dependency>
< dependency>
< groupId> org.hibernate.javax.persistence< / groupId>
< artifactId> hibernate-jpa-2.0-api< / artifactId>
< version> 1.0.0.Final< / version>
< / dependency>
<依赖>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-validator< / artifactId>
< version> 3.1.0.CR2< / version>
< exclusions>
< exclusion>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-api< / artifactId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< version> 3.3.1.ga< / version>
< exclusions>
< exclusion>
< artifactId> commons-logging< / artifactId>
< groupId> commons-logging< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> 3.3.0.CR2< / version>
< / dependency>
<依赖>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-ehcache< / artifactId>
< version> 3.3.0.CR2< / version>
< exclusions>
< exclusion>
< artifactId> jboss-logging< / artifactId>
< groupId> org.jboss.logging< / groupId>
< / exclusion>
< exclusion>
< artifactId> commons-logging< / artifactId>
< groupId> commons-logging< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> c3p0< / groupId>
< artifactId> c3p0< / artifactId>
< version> 0.9.1.1< / version>
< / dependency>
< dependency>
< groupId> antlr< / groupId>
< artifactId> antlr< / artifactId>
< version> 2.7.7< / version>
< / dependency>
< dependency>
< groupId> aopalliance< / groupId>
< artifactId> aopalliance< / artifactId>
< version> 1.0< / version>
< / dependency>
<依赖>
< groupId> javax.servlet< / groupId>
< artifactId> javax.servlet-api< / artifactId>
< version> 3.0.1< / version>
< / dependency>
< dependency>
< groupId> stax< / groupId>
< artifactId> stax-api< / artifactId>
< version> 1.0.1< / version>
< / dependency>
< dependency>
< groupId> org.apache.axis2< / groupId>
< artifactId> axis2-kernel< / artifactId>
< version> 1.6.1< / version>
< exclusions>
< exclusion>
< artifactId> servlet-api< / artifactId>
< groupId> javax.servlet< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.apache.ws.commons.axiom< / groupId>
< artifactId> axiom-api< / artifactId>
< version> 1.2.12< / version>
< exclusions>
< exclusion>
< artifactId> commons-logging< / artifactId>
< groupId> commons-logging< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-activation_1.1_spec< / artifactId>
< version> 1.0.2< / version>
< / dependency>
< dependency>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-javamail_1.4_spec< / artifactId>
< version> 1.6< / version>
< / dependency>
< dependency>
< groupId> jaxen< / groupId>
< artifactId> jaxen< / artifactId>
< version> 1.1.1< / version>
< exclusions>
< exclusion>
< artifactId> xercesImpl< / artifactId>
< groupId> xerces< / groupId>
< / exclusion>
< exclusion>
< artifactId> xml-apis< / artifactId>
< groupId> xml-apis< / groupId>
< / exclusion>
< exclusion>
< artifactId> xmlParserAPIs< / artifactId>
< groupId> xerces< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-stax-api_1.0_spec< / artifactId>
< version> 1.0.1< / version>
< / dependency>
< dependency>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-ws-metadata_2.0_spec< / artifactId>
< version> 1.1.2< / version>
< / dependency>
< dependency>
< groupId> org.apache.ws.commons.axiom< / groupId>
< artifactId> axiom-impl< / artifactId>
< version> 1.2.12< / version>
< exclusions>
< exclusion>
< artifactId> commons-logging< / artifactId>
< groupId> commons-logging< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.codehaus.woodstox< / groupId>
< artifactId> wstx-asl< / artifactId>
< version> 3.2.9< / version>
< / dependency>
< dependency>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-jta_1.1_spec< / artifactId>
< version> 1.1< / version>
< / dependency>
< dependency>
< groupId> commons-httpclient< / groupId>
< artifactId> commons-httpclient< / artifactId>
< version> 3.1< / version>
< exclusions>
< exclusion>
< artifactId> commons-logging< / artifactId>
< groupId> commons-logging< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> wsdl4j< / groupId>
< artifactId> wsdl4j< / artifactId>
< version> 1.6.2< / version>
< / dependency>
< dependency>
< groupId> org.apache.ws.commons.schema< / groupId>
< artifactId> XmlSchema< / artifactId>
< version> 1.4.7< / version>
< / dependency>
< dependency>
< groupId> org.apache.httpcomponents< / groupId>
< artifactId> httpcore< / artifactId>
< version> 4.0< / version>
< / dependency>
< dependency>
< groupId> com.javaetmoi.core< / groupId>
< artifactId> javaetmoi-spring4-vfs2-support< / artifactId>
< version> 1.4.0< / version>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-core< / artifactId>
< version> 3.2.13.RELEASE< / version>
< exclusions>
< exclusion>
< artifactId> commons-logging< / artifactId>
< groupId> commons-logging< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-aop< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-tx< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-expression< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
< dependency>
< groupId> org.springframework.retry< / groupId>
< artifactId> spring-retry< / artifactId>
< version> 1.0.3.RELEASE< / version>
< / dependency>
< dependency>
< groupId> javax.persistence< / groupId>
< artifactId> persistence-api< / artifactId>
< version> 1.0< / version>
< / dependency>
<依赖>
< groupId> com.oracle< / groupId>
< artifactId> ojdbc5< / artifactId>
< version> 11.2.0.1< / version>
< scope>提供< / scope>
< / dependency>
< dependency>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-api< / artifactId>
< version> 1.7.11< / version>
< / dependency>
< dependency>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-simple< / artifactId>
< version> 1.6.4< / version>
< / dependency>
<依赖>
< groupId> log4j< / groupId>
< artifactId> log4j< / artifactId>
< version> 1.2.17< / version>
< / dependency>
< dependency>
< groupId> commons-logging< / groupId>
< artifactId> commons-logging< / artifactId>
< version> 1.1.3< / version>
< / dependency>
< dependency>
< groupId> logkit< / groupId>
< artifactId> logkit< / artifactId>
< version> 1.0.1< / version>
< / dependency>
<依赖>
< groupId> org.apache.logging.log4j< / groupId>
< artifactId> log4j-api< / artifactId>
< version> 2.0< / version>
< / dependency>
< dependency>
< groupId> org.slf4j< / groupId>
< artifactId> log4j-over-slf4j< / artifactId>
< version> 1.7.11< / version>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-jdbc< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
< dependency>
< groupId> com.thoughtworks.xstream< / groupId>
< artifactId> xstream< / artifactId>
< version> 1.4.7< / version>
< / dependency>
< dependency>
< groupId> org.javassist< / groupId>
< artifactId> javassist< / artifactId>
< version> 3.18.1-GA< / version>
< / dependency>
< dependency>
< groupId> javax.batch< / groupId>
< artifactId> javax.batch-api< / artifactId>
< version> 1.0< / version>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-beans< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-context< / artifactId>
< version> 3.2.13.RELEASE< / version>
< / dependency>
< dependency>
< groupId> aopalliance< / groupId>
< artifactId> aopalliance< / artifactId>
< version> 1.0< / version>
< / dependency>
< dependency>
< groupId> javax.ws.rs< / groupId>
< artifactId> jsr311-api< / artifactId>
< version> 1.0< / version>
< / dependency>
< dependency>
< groupId> org.jboss.logging< / groupId>
< artifactId> jboss-logging< / artifactId>
< version> 3.3.0.Final< / version>
< / dependency>
< / dependencies>
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 3.1< / version>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>
< plugin>
< groupId> org.apache.axis2< / groupId>
< artifactId> axis2-wsdl2code-maven-plugin< / artifactId>
< version> 1.6.2< / version>
< executions>
< execution>
< goals>
< goal> wsdl2code< / goal>
< / goals>
< configuration>
< unpackClasses> true< / unpackClasses>
< packageName> com.globalss.data.processor.service< / packageName>
< wsdlFile> src / main / resources / wsdl / MonitoringService.wsdl< / wsdlFile>
< databindingName> xmlbeans< / databindingName>
< syncMode> sync< / syncMode>
< generateServerSide> true< / generateServerSide>
< generateServicesXml> true< / generateServicesXml>
< generateServerSideInterface> true< / generateServerSideInterface>
< / configuration>
< / execution>
< / executions>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-dependency-plugin< / artifactId>
< executions>
< execution>
< id> copy-dependencies< / id>
< phase> package< / phase>
< goals>
< goal> copy-dependencies< / goal>
< / goals>
< configuration>
< outputDirectory> $ {project.build.directory}< / outputDirectory>
< overWriteReleases> false< / overWriteReleases>
< overWriteSnapshots> true< / overWriteSnapshots>
< / configuration>
< / execution>
< / executions>
< / plugin>
< / plugins>
< resources>
< resource>
< directory> target / generated-sources / axis2 / wsdl2code / resources< / directory>
< / resource>
< resource>
< directory> target / generated-sources / xmlbeans / resources< / directory>
< / resource>
< resource>
< directory> src / main / resources< / directory>
< / resource>
< resource>
< directory> src / main / java / com / globalss / dnb / monitor / model /< / directory>
< targetPath> com / globalss / dnb / monitor / model /< / targetPath>
< includes>
< include> * .hbm.xml< / include>
< / includes>
< / resource>
< / resources>
< / build>
< / project>
我尝试了多种解决方案,但无法解决。
第一种方法)
在jboss-5.1.0.GA \lib\endorsed文件夹中我有这个jar (xercesImpl)
。
所以我删除了那个jar,然后运行项目。
现在我得到了这个异常
xception将上下文初始化事件发送到
类的监听器实例org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException :
从类路径资源解析XML文档的意外异常
[spring-batch-context.xml];嵌套异常是
javax.xml.parsers.FactoryConfigurationError:无法找到
javax.xml.parsers.DocumentBuilderFactory的提供者
2nd)方法
我试过评论pom.xml中的波纹管依赖项
<依赖性>
< groupId> jaxen< / groupId>
< artifactId> jaxen< / artifactId>
< version> 1.1.1< / version>
< exclusions>
< exclusion>
< artifactId> xercesImpl< / artifactId>
< groupId> xerces< / groupId>
< / exclusion>
< exclusion>
< artifactId> xml-apis< / artifactId>
< groupId> xml-apis< / groupId>
< / exclusion>
< exclusion>
< artifactId> xmlParserAPIs< / artifactId>
< groupId> xerces< / groupId>
< / exclusion>
< / exclusions>
< / dependency>
但我得到同样的例外
org.springframework.beans.factory.BeanDefinitionStoreException:
从类路径资源解析XML文档的意外异常
[spring-batch-context.xml];嵌套异常是
java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl无法在
org.springframework上转换为
javax.xml.parsers.DocumentBuilderFactory。 beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)
3rd)方法
我看到了一些关于同一问题的解决方案,并且解决方案说要添加波纹管依赖性
< dependency>
< groupId> xerces< / groupId>
< artifactId> xercesImpl< / artifactId>
< version> 2.11.0< / version>
< / dependency>
在我的pom.xml
中添加上述依赖项后,我得到此异常
org.jboss.xb.binding.JBossXBRuntimeException:无法在
org.jboss.xb创建新的
SAX解析器.binding.UnmarshallerFactory $ UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)
at
org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549)
at
org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:536)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig。 java:279)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at
org.apache.catalina.core.StandardContext。 init(StandardContext.java:5436)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)
4th)方法
我试图删除这个jar也是
这也适合我。
我对这个例外感到非常沮丧,但我无法解决这个问题,
这个链接非常好,它解决了同样的问题,但我仍然无法解决这个问题,任何人都可以帮我解决这个问题。
这是来自
Maven依赖的快照
所以这两个罐子有冲突。
所以我做了什么。构建项目后,我从
Myproject.war
中删除了(xml-api1.0.b2.jar)
并手动删除在Jboos
中部署项目,jboss不会抛出错误。
但是当我不删除
(xml-api1.0.b2.jar)
来自myproject.war
并在jboss中部署它会引发同样的错误。
所以我必须从
pom.xml
中删除依赖项。
for
(xml-api1.0.b2.jar)
我已经定义了以下方法
< dependency> <&的groupId GT; Jaxen的< /&的groupId GT; < artifactId的> Jaxen的< / artifactId的> <版本> 1.1.1< /版本> <排除> <排阻> < artifactId的> xercesImpl< / artifactId的> <&的groupId GT;&的Xerces LT; /&的groupId GT; < /排除> <排阻> < artifactId的> XML的API< / artifactId的> <&的groupId GT; XML的API< /&的groupId GT; < /排除> <排阻> < artifactId的> xmlParserAPIs< / artifactId的> <&的groupId GT;&的Xerces LT; /&的groupId GT; < /排除> < /排除>< /依赖性>
但是当我从
pom.xml
我仍然在Maven依赖中得到jar,就像我在图片中看到的那样。
我真的没有得到从这里
(xml-api1.0.b2.jar)
是卡明。任何人都可以通过查看我的pom来让我。 xml
。解决方案xml-api1.0.b2.jar 导入: poi-3.9 。
poi-3.9 依赖于dom4j,而dom4j包含 xml-api1.0.b2
因此,您可以将poi升级为 3.16 ,它将解决这个问题。I am using
java1.6
,jboss5.1
andSpring
maven3.2.5
in my project.I am gettingjava.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
This is my Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.varun.batch</groupId> <artifactId>myproject</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>myproject Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <!-- Spring ORM support --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.2.13.RELEASE</version> </dependency> <!-- Spring Batch --> <dependency> <groupId>org.springframework.batch</groupId> <artifactId>spring-batch-core</artifactId> <version>3.0.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.batch</groupId> <artifactId>spring-batch-infrastructure</artifactId> <version>3.0.1.RELEASE</version> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>2.5.0</version> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-transport-local</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-transport-http</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.6</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.9</version> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>3.1.0.CR2</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.3.1.ga</version> <exclusions> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.3.0.CR2</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>3.3.0.CR2</version> <exclusions> <exclusion> <artifactId>jboss-logging</artifactId> <groupId>org.jboss.logging</groupId> </exclusion> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.1</version> </dependency> <dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>stax</groupId> <artifactId>stax-api</artifactId> <version>1.0.1</version> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-kernel</artifactId> <version>1.6.1</version> <exclusions> <exclusion> <artifactId>servlet-api</artifactId> <groupId>javax.servlet</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.ws.commons.axiom</groupId> <artifactId>axiom-api</artifactId> <version>1.2.12</version> <exclusions> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-activation_1.1_spec</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-javamail_1.4_spec</artifactId> <version>1.6</version> </dependency> <dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.1</version> <exclusions> <exclusion> <artifactId>xercesImpl</artifactId> <groupId>xerces</groupId> </exclusion> <exclusion> <artifactId>xml-apis</artifactId> <groupId>xml-apis</groupId> </exclusion> <exclusion> <artifactId>xmlParserAPIs</artifactId> <groupId>xerces</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-stax-api_1.0_spec</artifactId> <version>1.0.1</version> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-ws-metadata_2.0_spec</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.apache.ws.commons.axiom</groupId> <artifactId>axiom-impl</artifactId> <version>1.2.12</version> <exclusions> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>wstx-asl</artifactId> <version>3.2.9</version> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jta_1.1_spec</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <version>3.1</version> <exclusions> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>org.apache.ws.commons.schema</groupId> <artifactId>XmlSchema</artifactId> <version>1.4.7</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.0</version> </dependency> <dependency> <groupId>com.javaetmoi.core</groupId> <artifactId>javaetmoi-spring4-vfs2-support</artifactId> <version>1.4.0</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.2.13.RELEASE</version> <exclusions> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>3.2.13.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.2.13.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>3.2.13.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.retry</groupId> <artifactId>spring-retry</artifactId> <version>1.0.3.RELEASE</version> </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc5</artifactId> <version>11.2.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.11</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.6.4</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>logkit</groupId> <artifactId>logkit</artifactId> <version>1.0.1</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>1.7.11</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.2.13.RELEASE</version> </dependency> <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>1.4.7</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.18.1-GA</version> </dependency> <dependency> <groupId>javax.batch</groupId> <artifactId>javax.batch-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.2.13.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.2.13.RELEASE</version> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.jboss.logging</groupId> <artifactId>jboss-logging</artifactId> <version>3.3.0.Final</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-wsdl2code-maven-plugin</artifactId> <version>1.6.2</version> <executions> <execution> <goals> <goal>wsdl2code</goal> </goals> <configuration> <unpackClasses>true</unpackClasses> <packageName>com.globalss.data.processor.service</packageName> <wsdlFile>src/main/resources/wsdl/MonitoringService.wsdl</wsdlFile> <databindingName>xmlbeans</databindingName> <syncMode>sync</syncMode> <generateServerSide>true</generateServerSide> <generateServicesXml>true</generateServicesXml> <generateServerSideInterface>true</generateServerSideInterface> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>true</overWriteSnapshots> </configuration> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>target/generated-sources/axis2/wsdl2code/resources</directory> </resource> <resource> <directory>target/generated-sources/xmlbeans/resources</directory> </resource> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory>src/main/java/com/globalss/dnb/monitor/model/</directory> <targetPath>com/globalss/dnb/monitor/model/</targetPath> <includes> <include>*.hbm.xml</include> </includes> </resource> </resources> </build> </project>
I tried multiple solutions,but could not resolve it.
1st method) In jboss-5.1.0.GA\lib\endorsed folder I have this jar
(xercesImpl)
. so I removed that jar, and run the project.Now I get this exception
xception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring-batch-context.xml]; nested exception is javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found
2nd) method I tried commented the bellow dependency from pom.xml
<dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.1</version> <exclusions> <exclusion> <artifactId>xercesImpl</artifactId> <groupId>xerces</groupId> </exclusion> <exclusion> <artifactId>xml-apis</artifactId> <groupId>xml-apis</groupId> </exclusion> <exclusion> <artifactId>xmlParserAPIs</artifactId> <groupId>xerces</groupId> </exclusion> </exclusions> </dependency>
But I get the same exception
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring-batch-context.xml]; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)
3rd) Method I saw some solution regarding the same problem and the solution says to add the bellow dependency
<dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.11.0</version> </dependency>
After adding the above dependency in my pom.xml I get this exception
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100) at org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549) at org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:536) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.StandardContext.init(StandardContext.java:5436) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)
4th) method I tried deleting this jar also
This also dint work for me.
I am damn frustrated with this exception, but I am not able to fix this,
This link is really good and it address the same problem, but still I am not able to fix this can any one help me this. Dealing with "Xerces hell" in Java/Maven?
Edited
I have found out the root cause. This is snapshot from
Jboss 5.1 Run-time
This is the snapshot from
Maven dependency
So this two jars are conflicting.
So What I did. After building the project I removed the
(xml-api1.0.b2.jar)
fromMyproject.war
and manually deployed the project inJboos
, and jboss does not throw error.But When I do not remove the
(xml-api1.0.b2.jar)
frommyproject.war
and deployed in jboss it throws the same error.So I have to remove the dependency from
pom.xml
.for
(xml-api1.0.b2.jar)
I have defined the bellow dependency<dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.1</version> <exclusions> <exclusion> <artifactId>xercesImpl</artifactId> <groupId>xerces</groupId> </exclusion> <exclusion> <artifactId>xml-apis</artifactId> <groupId>xml-apis</groupId> </exclusion> <exclusion> <artifactId>xmlParserAPIs</artifactId> <groupId>xerces</groupId> </exclusion> </exclusions> </dependency>
But when I comment this dependency from my
pom.xml
Still I get the jar in Maven dependency as I have shown in the image.I am really not getting from where this
(xml-api1.0.b2.jar)
is cumming. can any one let me by looking mypom.xml
.解决方案xml-api1.0.b2.jar is imported by : poi-3.9. The poi-3.9 depend on dom4j,and dom4j include xml-api1.0.b2 So,you can upgrade poi to 3.16,it will fix this problem.
这篇关于java.lang.ClassCastException:org.apache.xerces.jaxp.DocumentBuilderFactoryImpl无法强制转换为javax.xml.parsers.DocumentBuilderFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!