Question

I'm struck with a problem in jboss. When I try to deploy my .war into the server, I get this following error,

java.lang.ClassCastException: com.sun.org.apache.xerces.internal.jaxp.SAXParserF actoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory

from which, it is quite evident that there is a clash of libraries. So, I removed the jar file which contains xerces, which happened to by jaxp-ri-1.4.1.jar. Now, when I try to re-deploy, I get this new error,

java.lang.NullPointerException
    at org.apache.commons.digester.Digester.getXMLReader(Digester.java:944)
    at org.apache.commons.digester.Digester.parse(Digester.java:1765)
    at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java

where it is complaining that it can't find the xml parsers.

So, now my questions is that does anybody know what can be a solution. Any jaxp jar file that doesn't contain the xerces package?

Update

I did as suggested here and now I have a new error,

java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl

which is a class from one of the jars I deleted which contains SaxParserFactory :(

Was it helpful?

Solution

It appears that you've deleted the wrong JAR. The original ClassCastException was reported when an instance of SAXParserFactoryImpl (which is a subtype of SAXParserFactory) is being cast to SAXParserFactory.

The exception is more likely to be due to the fact that there are two instances of SAXParserFactory rather than two instances of SAXParserFactoryImpl being loaded in the JVM. At the time of casting, the SAXParserFactory loaded by a different classloader was returned resulting in the exception. The fix therefore is to identify JARs in your classpath that have conflicting versions of SAXParserFactory. Removing the parser implementation itself might not be wise, if Commons Digester is looking for a particular implementation.

OTHER TIPS

I'm guessing... You're using JBoss 5.1. If so then it's xml parser and classloading issue. You must define jboss-classloading.xml

See http://www.coderanch.com/t/523519/JBoss/Cast and http://www.mastertheboss.com/jboss-application-ser...oss-5-classloading-issues.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top