JBoss 5, Java 6, and DocumentBuilderFactory ClassCastExcepti
bdean42 Dec 15, 2008 2:19 PMSo we have a war file that deploys fine on on JBoss 4.2.2.GA with Java 6. However, when I try to deploy the same thing with JBoss 5.0.0.GA (from the jboss-5.0.0.GA-jdk6.zip file), I get the following exception (edited a bit):
00:00:00,000 ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [blah/some/package/spring-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:420) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:342) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:310) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader .loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader .loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader .loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader .loadBeanDefinitions(AbstractBeanDefinitionReader.java:212) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions (AbstractXmlApplicationContext.java:113) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions (AbstractXmlApplicationContext.java:80) at org.springframework.context.support.AbstractRefreshableApplicationContext .refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory (AbstractApplicationContext.java:423) at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:353) at org.springframework.context.support.ClassPathXmlApplicationContext.<init> (ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init> (ClassPathXmlApplicationContext.java:83) ... skipping a bunch of lines Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source) 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:396) ... 77 more
I'm not sure what to make of this other than that something about the way JBoss does jaxp stuff has changed and maybe the xercesImpl.jar isn't compatible with Java 6? (I really have no idea).
Also it should be mentioned that we are building our war files with hibernate inside our wars rather than using the hibernate included with JBoss (in case we want to ever deploy to something else). With that in mind, when I deployed the same war file but using Hibernate 3.2.6 it works fine with no DocumentBuilderFactory exception. But switching to Hibernate 3.3.1, I get the above exception. (Both wars with both versions of Hibernate deploy fine on the old JBoss 4.2.2 server).
I hope there's just some configuration file I didn't get set up quite right but I'm not sure. I've looked around a bit to see if other people have this problem and am not finding much of anything.