6 Replies Latest reply on Jan 10, 2002 8:23 PM by pbnj130

    java.lang.NoClassDefFoundError: javax/ejb/EJBHome

    pbnj130

      Hi all,

      I'm running the JBoss2.4.4_Tomcat4.0.1 bundle on Solaris 8. My problem is that JBoss doesn't seem to want to recognize the fact that the jboss-j2ee.jar is in the classpath even though from the print out, I can see that it is loaded from lib/ext:

      ...snip...
      [18:21:24,958,ClassPathExtension] Added library:file:/export/home/openspace/work/development/OpenSpace/Dep
      loy/AppServer/jboss/lib/ext/jnet.jar
      [18:21:24,959,ClassPathExtension] Added library:file:/export/home/openspace/work/development/OpenSpace/Dep
      loy/AppServer/jboss/lib/ext/jboss-j2ee.jar
      [18:21:24,960,ClassPathExtension] Added library:file:/export/home/openspace/work/development/OpenSpace/Dep
      loy/AppServer/jboss/lib/ext/catalina-service.jar
      ...snip...

      I also looked in the JBoss's server.log and the jar file is in java.class.path too. It deploys the tomcat-test.ear fine so I thought it was my code, but when I explicitly add jboss-j2ee.jar to JBOSS_CLASSPATH in run.sh, it works ( actually, it then complains that it can't find log4j, which has also been loaded from lib/ext, but at least it finds jboss-j2ee.jar). I found another post with the same problem, but no reply:

      http://www.mail-archive.com/jboss-user@lists.sourceforge.net/msg12536.html//www.mail-archive.com/jboss-user@lists.sourceforge.net/msg12536.html

      My output is below. Does anyone have an idea of what's going on? Thanks very much in advance and for this forum.

      abe

      [18:21:47,824,J2eeDeployer] Create application smi-adm-ejb.jar
      [18:21:47,825,J2eeDeployer] install EJB module smi-adm-ejb.jar
      [18:21:47,897,ContainerFactory] Deploying:file:/export/home/openspace/work/development/OpenSpace/Deploy/Ap
      pServer/jboss/tmp/deploy/Default/smi-adm-ejb.jar
      [18:21:48,180,ContainerFactory] Verifying file:/export/home/openspace/work/development/OpenSpace/Deploy/Ap
      pServer/jboss/tmp/deploy/Default/smi-adm-ejb.jar/ejb1004.jar
      [18:21:48,349,ContainerFactory] Verify failure
      java.lang.NoClassDefFoundError: javax/ejb/SessionBean
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:292)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:292)

      ...and so on

        • 1. Re: java.lang.NoClassDefFoundError: javax/ejb/EJBHome

          Can you give some details about how you have packaged
          this jar.

          You shouldn't have to add anything to your classpath.
          There is a service at the top of jboss.jcml that adds
          everyting in lib/ext to it. This is obviously running
          because that is the first part of your post.

          There are lots of problems posted about classpaths
          that involve confusion between Sun's j2ee.jar and jboss-j2ee.jar.
          Make sure you don't have Sun's version in
          your classpath or lib/ext of JAVA_HOME/jre/lib/ext
          or anywhere else this might cause confusion.

          Regards,
          Adrian

          • 2. Re: java.lang.NoClassDefFoundError: javax/ejb/EJBHome
            pbnj130

            > Can you give some details about how you have
            > packaged
            > this jar.
            That's right, I did forget to mention that I separated out the EJB code and the business logic using inheritance so that the EJB Remote interface, Home interface, and Bean class do not actually contain any functionality. Ie, the Bean class only has ejbCreate, ejbRemove, ejbActivate, ejbPassivate, and setSessionContext; it inherits all of the business logic from another class packaged in a jar file in the client dir (same goes for the Remote interface: it inherits all the business logic by extending another interface). I explicitly include this client jar file in the JBOSS_CLASSPATH in startup.sh.
            I don't think it's the inheritance that's causing this though cause I tried reorganizing so that all the functionality is in EJB and it still gave me the same error.
            Besides the Home, Remote, and Bean classes i just have my META-INF/jboss.xml and META-INF/ejb-jar.xml in the jar file.

            > Make sure you don't have Sun's version in
            > your classpath or lib/ext of JAVA_HOME/jre/lib/ext
            > or anywhere else this might cause confusion.
            Nope, I just the jboss-j2ee.jar

            abe

            • 3. Re: java.lang.NoClassDefFoundError: javax/ejb/EJBHome

              Have you tried putting client.jar
              in lib/ext
              another alternative is to create a .ear

              Don't use JBOSS_CLASSPATH.
              I saw a post some time ago that said it was called
              this to show JBoss didn't use the CLASSPATH
              environment variable, although I've also seen posts
              where people say dump whatever you like in there :-)

              Everyting in lib/ext is easy and doesn't require
              any editing of scripts.
              It also stops confusion between the class loaders
              like your log4j problem.

              Regards,
              Adrian

              • 4. Re: java.lang.NoClassDefFoundError: javax/ejb/EJBHome
                pbnj130

                > Have you tried putting client.jar
                > in lib/ext
                > another alternative is to create a .ear
                >
                > Don't use JBOSS_CLASSPATH.
                Yep...it looks like JBOSS_CLASSPATH is pretty sensitive to changes I've made and that's confusing the class loaders. I put the jar files in lib/ext, used the original JBOSS_CLASSPATH and it deployed fine. I was hoping to put folders in lib/ext though but that could be getting nitpicky :)

                Thanks for the help.

                abe

                >
                > Everyting in lib/ext is easy and doesn't require
                > any editing of scripts.
                > It also stops confusion between the class loaders
                > like your log4j problem.
                >
                > Regards,
                > Adrian

                • 5. Re: java.lang.NoClassDefFoundError: javax/ejb/EJBHome

                  You can have directories.

                  Have a look in conf/????/jboss.conf at classPathExtension.

                  NOTE: Everything is relative to the location of jboss.conf.

                  If you add





                  Providing you don't put a .jar or .zip in there
                  it will add the lib/ext/mydirectory to the classpath.

                  Putting a .jar or .zip in there, will only add the .jar
                  or .zip to the classpath.

                  Make a sentence out of the following words.
                  it eat and cake your have :-)

                  Regards,
                  Adrian

                  • 6. Re: java.lang.NoClassDefFoundError: javax/ejb/EJBHome
                    pbnj130

                    Sweet! Thanks much Adrian...

                    > You can have directories.
                    >
                    > Have a look in conf/????/jboss.conf at
                    > classPathExtension.
                    >
                    > NOTE: Everything is relative to the location of
                    > jboss.conf.
                    >
                    > If you add
                    >
                    > ARCHIVE="jboss.jar" CODEBASE="../../lib/ext">
                    > VALUE="../../lib/ext/mydirectory/">
                    >
                    >
                    > Providing you don't put a .jar or .zip in there
                    > it will add the lib/ext/mydirectory to the
                    > classpath.
                    >
                    > Putting a .jar or .zip in there, will only add the
                    > .jar
                    > or .zip to the classpath.
                    >
                    > Make a sentence out of the following words.
                    > it eat and cake your have :-)
                    >
                    > Regards,
                    > Adrian