Error when "xml-apis*.jar" or "xmlparserv2.jar" is packaged into a WAR on JBoss EAP5

Solution Verified - Updated -

Issue

  • Our applications are packaging xml-apis.jar, and this is causing a class loader issue. We noticed that JBoss was not ignoring classes in the javax package, and it iss our understanding that Tomcat, Weblogic and Jetty ignore classes in this package when loading the application. Can we make JBoss do that same to ease migration?

  • When we have xml-apis*.jar included in our war, we get a ClassCastException:

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/testApp]] (main) 
Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener         
java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
             at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)

OR

ERROR [[/TestApp]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
java.lang.ClassCastException: oracle.xml.jaxp.JXSAXParserFactory cannot be cast to javax.xml.parsers.SAXParserFactory
    at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)
    at com.sun.faces.config.ConfigureListener$WebXmlProcessor.getConfiguredFactory(ConfigureListener.java:702)
    at com.sun.faces.config.ConfigureListener$WebXmlProcessor.scanForFacesServlet(ConfigureListener.java:674)
    at com.sun.faces.config.ConfigureListener$WebXmlProcessor.<init>(ConfigureListener.java:648)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:156)
    at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:60)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4389)
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:321)

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 5.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.