3 Replies Latest reply on Sep 25, 2006 8:55 PM by Daling Xu

    problem with loader-repository and JAR in web-inf/lib

    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?

        • 1. Re: problem with loader-repository and JAR in web-inf/lib
          Scott Stark Master

          You cannot overload the jdk javax.* classes from the war deployment. Only the associated implementation classes should be in the jar. Remove the javax.* classes from the jar or configure the war class loader to ignore these using the jbossweb-tomcat55.sar/META-INF/jboss-service.xml FilteredPackages setting.

          • 2. Re: problem with loader-repository and JAR in web-inf/lib
            Samuel Rouiller Newbie

            From what I have tried, I see that the javax.xml classes are loaded from the JDK or JBoss anyway, no matter what I set in FilteredPackages

            How should I process to create an Oracle SAX parser with the following code if this code is in a class that is deployed in WARs web-inf/lib ?

            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();

            As reminder, the Oracle XML parser is in the EAR and its JAR is added to WAR's manifest classpath

            • 3. Re: problem with loader-repository and JAR in web-inf/lib
              Daling Xu Newbie

              I am facing exactly the same issue like you did.

              Did you solve it? How did you do it?

              Thanks

              "srouil" wrote:
              From what I have tried, I see that the javax.xml classes are loaded from the JDK or JBoss anyway, no matter what I set in FilteredPackages

              How should I process to create an Oracle SAX parser with the following code if this code is in a class that is deployed in WARs web-inf/lib ?

              SAXParserFactory factory = SAXParserFactory.newInstance();
              SAXParser parser = factory.newSAXParser();

              As reminder, the Oracle XML parser is in the EAR and its JAR is added to WAR's manifest classpath