[jboss-user] [EJB 3.0] - is mappedName needed to reference an EJB in JSF or not?
anthon.r
do-not-reply at jboss.com
Mon Mar 9 08:55:37 EDT 2009
JBoss 5.0.0.GA
Hi,
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:
@Stateless
| @EJB(name="audit", beanInterface=AuditLocal.class)
| public class MyBean implements MyBeanRemote, MyBeanLocal {
|
| SessionContext context;
| AuditLocal audit;
|
| public void setSessionContext(SessionContext context) {
| this.context = context;
| }
|
| @PostConstruct
| 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?
Thanks
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4216203#4216203
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4216203
More information about the jboss-user
mailing list