1 Reply Latest reply on Jan 16, 2003 9:07 PM by adrian.brock

    NoClassDefFoundError

    mspeck

      An interesting problem I solved just now.

      I am just starting using EJB's and created a Sequence bean for my application. Originally this was in my application package within the .war the I learned I should move it to the \server\default\deploy directory in it's own package. Within that package was an exception class that extended an ApplicationException class I had written in the application package.

      On deploy this would produce the afore mentioned error. I decided to add the Application.jar file to the classpath. The bean deployed fine however suddenly I was getting the same error on HTTPServlet.

      After much hairpulling and searching I found the statement on a post "...the classes within a .war file are not accessable from outside the .war file." I changed the exception class to inherit from java.lang.Exception and removed my classpath modifications and presto that problem went away.

      What I found interesting about this is that adding the Application.jar file to the classpath caused the rest of the packages to be inaccessable.

        • 1. Re: NoClassDefFoundError

          Classloaders are hierarchical.

          Wars
          UnifiedClassLoaders
          BootClassLoader
          Classpath

          You can only look above, if you are loading classes
          dynamically using the thread's application classloader.

          Thread.currentThread().getContextClassLoader().loadClass()


          This will fail.

          import InTheWar;
          public class InTheClassPath
          {
          }

          so will

          import InTheWar;
          public class InAnEJB // UnifiedClassLoader
          {
          }

          The only things in jboss's classpath are run.jar
          and the jre, so you won't be able to import
          very much. :-)

          Regards,
          Adrian