2 Replies Latest reply on Feb 8, 2012 3:06 PM by jtkim

    EAR migration problem: NoClassDefFoundError despite setting Class-Path

    jtkim

      I have an EAR that is deployable / operable in AS5 but I can't seem to get it to work in AS7. The EAR contains a plain vanilla jar and an ejbjar. A session bean in the ejbjar uses a class provided by the plain vanilla jar, but that results in failures, caused by a ClassNotFoundException. As far as I understand https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7, the ejbjar needs to declare its dependency on the plain vanilla jar using a Class-Path entry in its manifest. I've added that, but to no avail. So I've produced a minimal EAR that reproduces the problem hoping to stumble into the solution in this process, but no such luck -- so here goes:

       

       

      The EAR contains

      clp.ear

      +- clp.jar

      +- clp.war

      +- jarmodule.jar

      +- META-INF

         +- MANIFEST.MF

         +- application.xml


      clp.jar is the ejbjar, containing:

       

      clp.jar

      + clp

      | +- ejb

      |    +- session

      |       +- DemoSessionBean.class

      |       +- DemoSession.class

      + META-INF

         +- MANIFEST.MF

       

      where MANIFEST.MF contains

       

      Manifest-Version: 1.0

      Class-Path: jarmodule.jar

      Created-By: 1.6.0_27 (Sun Microsystems Inc.)

       

      So I expect the class jarmodule.Blah from jarmodule.jar to be available, so in my DemoSessionBean there should not be any problem with the method sayBlah:

       

      import jarmodule.*;
      
      @Stateless
      @Remote(DemoSession.class)
      public class DemoSessionBean implements DemoSession, Serializable
      {
        private static final long serialVersionUID = 1;
      
        public void sayBlah()
        {
          Blah blah = new Blah();
          blah.blah();
        }
      }
      

       

      However, invoking this method results in

       

      00:54:21,394 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/clpdemo].[welcome]] (http--127.0.0.1-8080-1) Servlet.service() for servlet welcome threw exception: javax.ejb.EJBException: Unexpected Error
      ...
      Caused by: java.lang.NoClassDefFoundError: jarmodule/Blah
      ...
      Caused by: java.lang.ClassNotFoundException: jarmodule.Blah from [Module "deployment.clp.ear.clp.jar:main" from Service Module Loader]
      

       

      So, can anyone please direct my unfocused gaze towards the core of this problem, and towards its solution? I attach an archive containing the minimal example and a script for building the ear for you to examine, in case I've managed to omit the key detail in my posting above.

       

      Thanks in advance, Jan