3 Replies Latest reply on Apr 17, 2010 3:26 PM by alesj

    isolated classloading for war file

      Hi,

       

      I have a .war and .sar deployed in JBoss 5 which both require spring framework version 3 jars. We have other services deployed which use spring version 2 and the JAR for that version is in the server lib directory.

       

      I can get the .sar to use its local spring JARs using the jboss-classloading.xml file in the META-INF directory, however it won't seem to work for the war file.

       

      test.sar/META-INF/jboss-classloading.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <classloading xmlns="urn:jboss:classloading:1.0"
          name="test.sar"
          domain="test.sar.domain"
          parent-first="false"
          export-all="NON_EMPTY"
          import-all="false">
      </classloading>

       

      test.war/WEB-INF/jboss-classloading.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <classloading xmlns="urn:jboss:classloading:1.0"
           name="test.war"
           domain="test.war.domain"
           parent-first="false"
           export-all="NON_EMPTY"
           import-all="false">
      </classloading>

       

      I get this error:

       

      11:27:58,131 ERROR [[/test]](main) Servlet /test threw load() exception
      java.lang.IllegalArgumentException: Class [org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler] does not implement the NamespaceHandler interface

       

       

      Looks like its still picking up classes from the spring v2 jar in the server lib directory. It seems that altering the classloading policy with the jboss-classloading.xml file works for the .sar but not the .war. Could someone advise me where I'm going wrong?

       

      Thanks,

      Brad.

        • 1. Re: isolated classloading for war file
          alesj
          test.war/WEB-INF/jboss-classloading.xml:

           

          <?xml version="1.0" encoding="UTF-8"?>
          <classloading xmlns="urn:jboss:classloading:1.0"
               name="test.war"
               domain="test.war.domain"
               parent-first="false"
               export-all="NON_EMPTY"
               import-all="false">
          </classloading>

           

          I get this error:

           

          11:27:58,131 ERROR [[/test]](main) Servlet /test threw load() exception
          java.lang.IllegalArgumentException: Class [org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler] does not implement the NamespaceHandler interface

           

          Looks like its still picking up classes from the spring v2 jar in the server lib directory. It seems that altering the classloading policy with the jboss-classloading.xml file works for the .sar but not the .war. Could someone advise me where I'm going wrong?

           

          First, for .war/web you actually don't need to specify parent-first=false, since this is deafult .war/web spec behavior.

          For the actual problem, I'll think about it over the weekend and get back to you -- cannot see it on the spot on Friday afternoon. :-)

          • 2. Re: isolated classloading for war file

            Hi Ales,

             

            this turned out to be due to my .war missing spring web servlet jar which was making it use the spring v2 jar in server lib for some reason.

             

            sorry for wasting your time, hope I caught you before you left for the weekend!

             

            Thanks,

            Brad.

            • 3. Re: isolated classloading for war file
              alesj
              this turned out to be due to my .war missing spring web servlet jar which was making it use the spring v2 jar in server lib for some reason.

              "for some reason" - well, it tries to find it in the parent, which it then does; hence CCE