4 Replies Latest reply on Jul 26, 2006 6:36 PM by Todd Main

    Remote EJBs

    Todd Main Newbie

      I'm having a difficult time with the concept of my JSP page directly working with EJBs, but I'm trying to let go of the past. I totally bought into the "business delegate" and "value object" architecture for hiding the fact that I used EJBs, etc.

      Any comments about how this (directly referencing EJB from a JSP) is no longer evil (if it ever was)?

      I do have a few EJB questions:

      1. How do I access a remote EJB using Seam? I don't necessarily mean all beans would be remote. I'm working with an application that would need to interact with several sets of services, some local and some remote. I'm wondering if there is some Seam magic for this, so I don't have to have gooey jndi/home iface/remote iface junk in my app.

      2. Also, is there anything special I need to do to make one of my EJB sessions also respond to remote calls? [I don't know too much of the EJB3 stuff yet, but I'm hoping I could just add the "@Remote" annotation to the interface - however, how would it be registered with jndi?]

      3. What happens on my web page when the JSF listener is a remote session bean and its server is down (our old friend RemoteException)? Is that handled gracefully by Seam, or is there a mechanism for me to handle it gracefully?

        • 1. Re: Remote EJBs
          Gavin King Master

          1. At least in CVS it is conceptually possible to have a remote Seam component. (I forget whether a nonbuggy implementation made it into 1.0.1.)

          However, this feature requires that the implementation class for the remote bean is in the client classpath, which is not usually the case. (I'm not quite sure what I can do about that one .... I suppose I can support @Name on remote interfaces...?)

          Alternatively, you can just call the remote EJB using normal EJB3 mechanisms, inject it using @EJB.

          2. You need a dedicated remote interface, annotated @Remote.

          3. You need to implement your own exception handling layer for this. Either deal with the exception in client code, or in a servlet filter or web.xml. Unfortunately JSF (amazingly) does not provide any good place to handle these kinds of exceptions :-(

          • 2. Re: Remote EJBs
            Gavin King Master

             

            "gavin.king@jboss.com" wrote:
            3. You need to implement your own exception handling layer for this. Either deal with the exception in client code, or in a servlet filter or web.xml. Unfortunately JSF (amazingly) does not provide any good place to handle these kinds of exceptions :-(



            Hmmmm. One thing I *could* do is have Seam provide a client-side interception layer for EJB components (a feature missing from the EJB spec). And then I could provide a built-in interceptor for handling the spec-defined exceptions (ConcurrentAccessException, RemoteException, etc).


            • 3. Re: Remote EJBs
              Gavin King Master

              OK, so I have implemented client-side interceptors for Seam. All you do is write a normal Seam interceptor (using @Interceptors as a meta-annotation),
              and then annotate the actual interceptor class @Interceptor(type=CLIENT).

              That is a good place to handle stuff like remote exceptions.

              • 4. Re: Remote EJBs
                Todd Main Newbie

                That was fast! I found the section on interceptors in the Seam reference, but that section seems to be describing interceptors that happen before a particular action is executed.

                I'm assuming this means that I need to read up on the EJB3 spec some more to find out about client-side interceptors.

                Man, I have a lot of catching up to do after two years of maintaining a legacy app!