4 Replies Latest reply on Jan 30, 2003 3:14 AM by gfloodga

    JBoss/Jetty classloading problem

    sny23

      Hi there.

      I got a problem with moving an existing webapp from a standalone TomCat 3.3 onto an JBoss-3.2.0 w/Jetty installation.

      I installed the webapp as ear/war (unpacked, just the directory structure) into jboss. The classpath setup is fine and when the servlet inits, the neccessary classes are loaded from one of the jars fine, too. But then some way down the road it throws a java.lang.NoClassDefFoundException for a class that is contained in the very same jar file as the main servlet class itself.

      When testing different possibilities I learned that moving the jar in question to the server/default/lib directory actually solves the problem. But then again it is visible to all other apps _and_ it is separated from the webapp as such. It would therefore be nice to be able to retain the overall webapp structure and load the class files as intended instead of moving them to the lib dir.

      Anybody with experience in this matter please assist.
      Thanks, Marko

        • 1. Re: JBoss/Jetty classloading problem
          gfloodga

          This sounds like a classloader issue - it wouldn't be tiles by any chance ?

          I have seen the same, moving from war to ear. For clues, may I suggest the Wrox Java Sever Programming 1.3 book chapter 24. It is a useful guide.

          Alternatively, try extracting the classes that fail to load (and all their dependancies) out into a separate jar, that is inside the EAR. Then put in the manifset.mf a reference to the jar in the classpath line.

          Hope this helps


          • 2. Re: JBoss/Jetty classloading problem
            sny23

            OK, I think I read about this approach before.

            BUT what I just don't understand is the fact that the main servlet class (and those that it extends/implements) DO GET loaded alright from the very same jar file that contains the others. So it looks to me as if this were a different behaviour between servlet initialization and execution.

            Anyway, I'm gonna try this and see if it works that way.

            BTW, If I need more than one jar, can I set the classpath in Manifest.mf to a set of those?

            • 3. Re: JBoss/Jetty classloading problem
              sny23

              OK, got it working, following yet another approach described elsewhere in the forums.

              What I did was to move the jars from the war's
              WEB-INF/lib
              to the ear's ROOT and include them as
              _name_.jar
              into the application.xml file.

              Still, as also described in the appropriate entry, this seems to be some kind of bug with the visibility of the jars inside the war which in turn is inside an ear. It is said that it works with the war standalone, but then you cannot easily set up another webcontext, can you?

              Still, this is a whole lot better than copying all the jars into server/default/lib.

              Marko

              • 4. Re: JBoss/Jetty classloading problem
                gfloodga

                Hi Marko,

                I didn't know about that way of doing things. Useful to know, any ideas on best practice here ?

                But as you said at least it's better that default/lib!!

                Regards

                Gareth

                PS: yes you could specify a set of jars in the manifest.mf