7 Replies Latest reply on Aug 22, 2003 8:29 AM by juhalindfors

    strange problem -  NoClassDefFoundError

    surekharao Newbie


      I have very strange problem ..

      Well .. I am getting java.lang.NoClassDefFoundError: when my bean is calling other bean classes out side of package , If I packaging the importing interface classes in the same jar as the calling bean then working very fine..

      Is this any bug type?

      Pls suggest me what could be the problem with my bean..

      thanks in advance


        • 1. Re: strange problem -  NoClassDefFoundError

          What version of JBoss are you using and how are you packaging and deploying your application?

          -- Juha

          • 2. Re: strange problem -  NoClassDefFoundError
            surekharao Newbie

            Hi juwa

            Thanks for your reply

            sorry for late reply since I was on vacation
            well .. I am using Jboss -2.4.4 and Tomcat -4.0.3 both are standard alone And my package structure is like below:

            UserBean module

            com.sms.user.ejb.*; --> calling bean package
            UserControlBean--> Bean class
            UserControl---> Remote Interface
            UserControlHome--> Home Interface

            MilageBean module

            com.sms.milage.ejb.*; --> other bean package
            MilageControlBean--> Bean class
            MilageControl---> Remote Interface
            MilageControlHome--> Home Interface

            Problem :

            When I call MilageControlHome in my calling bean(UserControlBean) getting exception java.lang.NoClassDefounderErrorException

            The below code is where my bean calling other beans out side of package

            Context ctx = EJBUtil.getInitialContext();
            MilageControlHome milageHome = (MilageControlHome) EJBUtility.getEJBHome(ctx,"com/sms/milage/ejb/MilageControlHome",MilageControlHome.class);
            MilageControl milageControl = milageHome.create();

            And as I told if I packaged other bean classes in my calling bean package then it didn't give any exception and working very fine

            I doubt some thing wrong in classpath, I have checked already my classpath settings and pretty sure there is nothing wrong.

            So confusing what is the real problem with this..
            Pls refer once this once and help me out.

            Thanks in advance


            • 3. Re: strange problem -  NoClassDefFoundError

              You need to package the bean interfaces with the components that are using them to call your bean implementation.

              Or create an EAR archive that contains all your EJB jars.

              -- Juha

              • 4. Re: strange problem -  NoClassDefFoundError
                surekharao Newbie

                Hi Juha.

                I really don't get u r point.. could u please explain more clearly..
                let me explain my package struchere once

                I have made .jar files (which are stroing in /JBOSS_HOME/deploy ) for each module which contains Session Beans and CMP -Entity Beans

                For your reference here with attaching make file for one of my user module

                And also could you please explain how to create EAR with all my EJB jars
                thanks for u r help


                • 5. Re: strange problem -  NoClassDefFoundError

                  If you're deploying two EJB jars in 2.4 what you get is two separate classloaders, one per jar, that do not have visibility to each other's loaded classes. That means that if you are using bean from jar B then you need to include the component interfaces (home and remote interfaces, custom types exposed in those interfaces) as part of jar A when invoking a bean from within that jar.

                  If you package both EJB jars in an EAR then the EAR file shares a single classloader and will have class visibility across all components inside the EAR. EAR packaging is explained in most J2EE tutorials available on the web. It is a standard J2EE package format.

                  -- Juha

                  • 6. Re: strange problem -  NoClassDefFoundError
                    surekharao Newbie

                    Hi Juha !

                    thanks for ur reply

                    I tried to make EAR Package, so I put all my deployed jars in EAR package directory
                    and inside package directory made META-INF folder there put application.xml






                    Added all my jars here

                    Here is ear file smsbean.ear) is built, using the jar command

                    cd smsbeans (EAR package Directory)
                    jar cvf smsbeans .ear *

                    After that I copied smsbeans.ear file to $JBOSS_HOME/deploy/
                    then I can see log trace($JBISS_HOME/bin/noput.out) showing errors and smsbeans .ear is not deployed.

                    Am I doing on right way or missing any thing?
                    Please check once ..

                    Thanks for your help


                    • 7. Re: strange problem -  NoClassDefFoundError

                      can you please attach the errors you get in the console or server.log that are causing the deployment to fail?

                      -- Juha