<env-entry> and @Resource in EJBs are behaving differently in EAP5 Vs EAP6
Issue
- Why the EAP5 and EAp6 are behaving differently regarding
and @Resource annotations ? - In EAP5 when the following annotation (@Resource) is used then it works properly application deploys and the value of result is populated as "MyStringEntryFromEJBAnnotation":
@Stateless(name="SomeServiceBean")
public class SomeServiceBean implements SomeService {
@Resource(name="MyEntry" , type=java.lang.String.class, mappedName="MyStringEntryFromEJBAnnotation")
String result;
}
- However When the same is used in EAP 6.0.1 then we see the following Error at the time of deployment:
12:45:54,869 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "TestEJBRef_EAP6.ear"
12:45:54,871 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.comp.TestEJBRef_EAP6.testEJB.SomeServiceBean.env.MyStringEntryFromEJBAnnotation (missing) dependents: [service jboss.naming.context.java.comp.TestEJBRef_EAP6.testEJB.SomeServiceBean.env.MyEntry]
- In order to avoid getting the above exception we need to add the following kind of entry inside the META-INF/ejb-jar.xml of the above EJB, then it works properly application deploys and the value of result is populated as "MyStringEntryViaEjbJarXML":
<env-entry>
<env-entry-name>MyEntry</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>MyStringEntryViaEjbJarXML</env-entry-value>
</env-entry>
Environment
- JBoss Enterprise Application Platform (EAP)
- 6.0.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
