3 Replies Latest reply on Oct 24, 2001 5:30 AM by Ben

    Two dependent EJBs

    Jon Evans Newbie


      I'm fairly new to EJB. I'm using the latest stable JBoss, so that's EJB 1.1 spec. I'm posting this question here as I'm fairly certain its a generic EJB question, not JBoss specific.

      I've defined a CustomerEJB (firstname, surname etc). and an AddressEJB (street, town, postcode etc.). I did it like that because potentially lots of objects in my app will need addresses, for instance CustomerEJB may end up with invoiceAddress and deliveryAddress.

      My CustomerEJB has a getAddress method which does a lookup and returns an AddressRemote.

      When I try to deploy CustomerEJB, I get an exception because AddressRemote cannot be found by the classloader, even though AddressEJB has deployed OK.

      What is the best strategy here? Add AddressRemote.class to CustomerEJB.jar? What if I make some additions to the AddressRemote interface in the future, I don't want to have to deploy a new CustomerEJB. Should I just let the Customer class expose the Integer addressID and let the caller resolve it to an AddressEJB?

      Your thoughts are appreciated...



        • 1. Re: Two dependent EJBs
          Marcus Brito Novice

          Perhaps you should add both beans .jar files to a single .ear file. JBoss puts all jar files contained it the ear in the classpath for the application.

          • 2. Re: Two dependent EJBs
            Noel Hebert Newbie


            As you describe your EJB deployment as being two
            jar files, it is important to view deployed
            jar, war, and ear files as *separate* deployment
            units. As such they would have no class loader
            visibility across the deployment units.

            If there are any dependencies, you must include
            the Home and Remote interfaces of the dependent
            component. That way you have visibility even
            if the dependent component is deployed in another
            app server.

            It is an easy trap to view a JBoss app server
            install as an island. It might not be. It may be
            part of a federation of app servers running on
            different machines. In this very possible scenario
            class loader visibility across deployment units
            on seperate machines is impossible.

            As Marcus, pointed out, if you have close coupling
            where two components always occur together, then it
            makes sense to deploy them togther in the same

            Just my thoughts.



            • 3. Re: Two dependent EJBs
              Ben Newbie

              Have a look at the answer I gave to Rich at theis address. It may be just what you are looking for.

              http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ luck,