3 Replies Latest reply on Mar 10, 2009 9:11 AM by jaikiran pai

    is mappedName needed to reference an EJB in JSF or not?

    Anthon Ranullo Newbie

      JBoss 5.0.0.GA


      I'm exhausted searching for some enlightenment on whether the attribute "mappedName" in @EJB is needed or not in a JSF Managed Beans. Could please anyone enlighten me on this subject? I'm getting error message like "Resolution should not happen via injection container" if I don't specify mappedName. I want to avoid mappedName as much as possible. Or is it unavoidable?

      Also, what's the difference between applying @EJB to field from applying to a class? Consider the following example:

      @EJB(name="audit", beanInterface=AuditLocal.class)
      public class MyBean implements MyBeanRemote, MyBeanLocal {
       SessionContext context;
       AuditLocal audit;
       public void setSessionContext(SessionContext context) {
       this.context = context;
       public void init() {
       audit = (AuditLocal) context.lookup("audit");
       // ...

      My guess is, if @EJB is declared at the class level, the container tries to inject the session bean into java:/comp/env/audit JNDI name instead of injecting it to the field directly as opposed to @EJB that is declared at the field level. Did I get it right?

      And it knows what EJB to inject in java:/comp/env/audit by relying on the value of beanInterface attribute, is that right?