2 Replies Latest reply on Jun 21, 2006 2:02 AM by David Richmond

    Classloading problem when using loader-repository and JAR in

    Samuel Rouiller Newbie

      Hi,

      I have an EAR that uses loader-repository with overidding of JBoss classes.
      Structure of my app is:

      jbosscltest.ear
      - xmlparserv2.jar (Oracle XML parser implementing JAXP)
      - corefw.jar (core fw classes using XML parser)
      - webapp.war (web app using core fw)
      - web-inf/lib
      - struts.jar

      (descriptors and manifest files are not shown above)

      jboss-app.xml defines loader-repository with java2ParentDelegation=false
      Manifest file of WAR adds xmlparserv2.jar and corefw.jar in classpath

      I get ClassCastException in struts code that parses struts-config.xml. It looks like struts has loaded another version of javax.xml.parsers.SAXParserFactory than the one in xmlparserv2.jar and makes a CCE because javax.xml.parsers.SAXParserFactory loads the implementation of Oracle parser.

      2006-02-19 09:10:19,463 INFO [STDOUT] java.lang.ClassCastException: oracle.xml.jaxp.JXSAXParserFactory
      2006-02-19 09:10:19,473 INFO [STDOUT] at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
      ...

      I can solve my problem
      - by moving struts from WAR web-inf/lib to EAR (is it really correct, struts beeing used only in my webapp?)
      - by settting UseJbossWebLoader to true (I cannot afford this because of the risk of class conflicts between the several WARs in my EAR)

      Why does Struts load javax.xml.parsers.SAXParserFactory from JBoss instead of xmlparserv2.jar?