I apologize if I should ask this in the EJB or JBOSS forums, but it seemed to be a general @Resource questions. I am not sure I understand how the @Resource annotation works. I am running on java 1.7, JEE 6, and JBOSS AS 7.1.
The javax.annotation.Resources documentation indicates that the name parameter is the JNDI name of the resource. But lookups that fail using a JNDI name and thev@Resource annotation succeed when a JNDI context is obtained and used to look up the resource. For example in the code below I can successfully get a mail session if I comment out the @Resource annotation and uncomment the @PostConstruct annotation. In both cases the string I use for JNDI name is "mail/yahoo"
If I run the code as shown attempting to use the @Resource annotation jboss reports the following error:
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.comp.EJB05EAR.CHAP05EJB.StatusMailerBean.env.mail.yahoo (missing) dependents: [service jboss.deployment.subunit."EJB05EAR.ear"."CHAP05EJB.jar".component.StatusMailerBean.START]
The configuration entry in standalone.xml for the mail session is