I'm using JBoss 4.2 and jdk6.
How can i only load javax.xml.parsers.DocumentBuilderFactory from xmlparserv2.jar in my webapp ?
When i used -verbose:class, javax.xml.parsers.DocumentBuilderFactory loaded by jdk6 :
[Loaded javax.xml.parsers.DocumentBuilderFactory from C:\Program Files (x86)\Java\jdk1.6.0_21\jre\lib\rt.jar]
and by xmlparserv2.jar
I have the following trace when Spring load. I use Spring core 3.1.3.
INFO [STDOUT] ERROR [main] (ContextLoader.java:307) - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/classes/conf/applicationContext.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:412)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174
...
Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:29)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 149 more
MyEar
- lib
...
xmlparserv2.jar
...
- META-INF
application.xml
jboss-app.xml
+ mywar.war
I have nothing in the WEB-INF/lib from the war.
I can't remove xmlparserv2.jar because i need the oracle implementation of XMLNode in some jar.
Are there solutions without migrate JBoss to an older version ?
Could you use a system property to force the specific Factory you want?
Quoting info from here...