In a Java EE 6 Web application, I would like to access a deployment parameter (a string value) from within an EJB
.
I know that I can define a Context Pa
After further research, I have found out the use of env-entry
annotation in web.xml
.:
<env-entry>
<env-entry-name>myEnvEntry</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>MyEnvEntryValue</env-entry-value>
</env-entry>
The env-entry
can be accessed in various ways from an EJB
. The simplest is the use of @Resource
annotation (requires CDI):
@Resource(name="myEnvEntry")
private String myEnvEntry;
Links: Configure your EJB 3 with envirnoment entries using ENC