2 Replies Latest reply on Sep 27, 2009 10:11 PM by Kevin Keigwin

    Session Bean with Multiple Interfaces and @LocalBinding

    Kevin Keigwin Newbie

      I'm using JBoss 5.1 and have an EJB 2.1 application that I'm migrating to EJB 3.0. In this application, there are stateless session beans that expose two different interfaces. For example, there is a bean called UserServiceBean which has a local interface called UserServiceLocal and another local interface called UserAdminLocal. UserServiceLocal exposes the methods needed by the main application, while UserAdminLocal extends UserServiceLocal to provide those same methods plus some new ones to our administrative application.

      As part of the migration from 2.1 to 3.0, I am using the @LocalBinding annotation to ensure that the JNDI names of the migrated and un-migrated session beans stays consistent.

      Now I've run into a problem. It appears I can't use @LocalBinding to bind the same session bean to JNDI twice (once for each interface). When I try to do this, I get the following error from JBoss at startup:

      Deployment "vfszip:/C:/Program%20Files/jboss-5.1.0.GA/server/web/deploy/SellCoreComponentEAR.ear/" is in error due to the following reason(s): java.lang.AssertionError: Currently only 1 @LocalBinding is supported for EJB UserServiceBean

      I've also tried pushing the methods for the Admin interface down into a subclass so that I could provide a different @LocalBinding there, but I get the same result.

      Can anyone suggest a way to solve this other than by creating two bean classes, one of which is a delegate to the other?

      Thanks in advance,

      Kevin

        • 1. Re: Session Bean with Multiple Interfaces and @LocalBinding
          jaikiran pai Master

          The @LocalBinding annotation is for the default business interface proxy of the bean (which will implement all the local business interfaces). If you want to lookup interface specific proxy, we already bind those to the JNDI with the following syntax:

          BeanName/local-InterfaceFullyQualifiedName


          Example:

          UserServiceBean/local-xxx.yyy.UserAdminLocal

          UserServiceBean/local-xxx.yyy.UserServiceLocal
          


          You will be able to see these JNDI names on the console.


          • 2. Re: Session Bean with Multiple Interfaces and @LocalBinding
            Kevin Keigwin Newbie

            Thank you for your response. However, if you look in my original post, I explained that:

            "As part of the migration from 2.1 to 3.0, I am using the @LocalBinding annotation to ensure that the JNDI names of the migrated and un-migrated session beans stay consistent."
            This means that I do not want to use the default JBoss JNDI bindings, because they follow a different pattern than those of our 2.1 beans. My question is whether I can define different bindings for the different interfaces that a bean implements. It's looking like the answer is "no", since you cannot have more than one @LocalBinding annotation.