10 Replies Latest reply on May 27, 2003 3:16 PM by kindoblue

    EJB inheritance

    kindoblue Newbie

      I have several ejbs, stored in different jars, that inherit from a base ejb. When I deploy them I get "class not found" errors if the base ejb classes are not stored in the same jar of the ejbs I'm trying to deploy.
      The problem is that I would like to have a separate jar with the base classes, stored with other ejb jars in a ear for example, but it doesn't work (jboss 3.2). I could copy the base classes in each ejb jar but I wonder if there is a better solution.

      Thank in advance

        • 1. Re: EJB inheritance
          Jon Barnett Master

          Does it work if you put the jar with the base classes in the lib directory of the JBoss instance? e.g. server/default/lib of the distribution if you are running the default instance. This works for me since we actually use some framework components across multiple web applications.

          • 2. Re: EJB inheritance
            Harald Gliebe Novice

            Use the manifest classpath to reference the required jars: If you put a line

            Class-Path: [space-separated list of jar files]

            in the META-INF/MANIFEST.MF file of you jar file the classes of the listed jar's are added to the classpath.


            • 3. Re: EJB inheritance
              kindoblue Newbie

              Sorry for this duplicate post, but the forum interface signaled an error in posting my first message...

              • 4. Re: EJB inheritance
                Nikos Paraskevopoulos Newbie


                I did solve this in the following, quite simple way:

                First put all your base classes and generally all shared classes in a separate jar (say libs.jsr). This jar should be included in your ear file, perhaps under the directory /library to keep things tidy.

                Then add this line to the META-INF/MANIFEST.MF file of the ejb jar file:

                Class-Path: library/libs.jar

                Good luck!

                • 5. Re: EJB inheritance
                  kindoblue Newbie

                  hi all,

                  I've already tried to use the Class-path property in the manifest file and it doesn't work for my case.
                  I try to explain better my problem: imagine you have an ejb and its implementing class is called ClassA, so in ejb-jar.xml there's a line as the following


                  imagine also that ClassA extends ClassFather. The problem I experienced is that during deploy the EJB verifier tells me the ClassA is not found IF the ClassFather is not in the same jar.
                  So the base classes I use are not merely helper classes (like logger ones or something like that).
                  It seems to me that the deployer needs all the classes in the hierarchy to succeefully deploy the ejb, so until now the only thing to circumvent the problem is to copy in every ejb jars those base classes.

                  • 6. Re: EJB inheritance
                    Jon Barnett Master

                    OK. Again I ask - does it work if you put the parent class in the lib directory for the JBoss instance? This is what we do and we extend the parent in the actual EJB implementation (the child). This works for us. At least we can work backwards from there to where you want to be. It may be a classloader issue but we won't know until someone does some empirical work first.

                    • 7. Re: EJB inheritance
                      kindoblue Newbie

                      Sorry, I missed the point :-) I will try to put the base jar in server/default/lib and see what happens.
                      My last post was written only to clarify better the problem. Sorry again


                      • 8. Re: EJB inheritance
                        kindoblue Newbie


                        I've deployed my ear after having placed the base jars in server/default/lib also. The problem remains the same:

                        2003-05-26 21:04:31,430 WARN [org.jboss.ejb.EJBDeployer.verifier] EJB spec violation:
                        Bean : MyBean
                        Section: 22.2
                        Warning: The Bean Provider must specify the fully-qualified name of the Java class that implements the enterprise bean's business methods in the <ejb-class> element.
                        Info : Class not found: com.some.package.ClassA

                        actually the ClassA is present in the ejb jar. The parent class, instead, is not in the same ejb jar, but in a utility jar placed in the ear and in server/default/lib also.
                        After the warning the deployer complains about other classes missing (present in the base jar as well) and drop the ear undeployed.

                        The jboss version is 3.2.1

                        Thanks in advance for help

                        • 9. Re: EJB inheritance
                          Jon Barnett Master

                          OK. Just wondering if this is a classloader scope problem. Our beans are shared across multiple applications so they actually float outside of EARs. And they work. So perhaps you could try placing them (your EJBs) outside the EAR and straight in the deploy directory. That might give a better idea of whether it is related to anything strange with loading within an EAR. If it still doesn't work, then we know it isn't related to this and we must look elsewhere.

                          • 10. Re: EJB inheritance
                            kindoblue Newbie


                            unfortunately it doesn't work, even if the ejb jars are deployed as is and not wrapped in a ear. Actually I made my first attemps not using ear :-)
                            At this point I prefer to put the base classes in the ejb-jar, rather than to investigate further, as the time go fast