users@glassfish.java.net

Re: Environment Entry in EJB3.1

From: <glassfish_at_javadesktop.org>
Date: Fri, 09 Apr 2010 10:49:03 PDT

Hi Ksak,
Thanks for your fast reply and sorry for my late response.
Though I was looking for a way to define the Environment Entries in EJB deployment descriptor, as you suggested, I put the application scope entry in application descriptor (application.xml) and it worked fine.
Again thanks for your kindness and information.

Here is the conclusion…
The ejb-jar.xml seems to not be able to define Application Scope Environment Entries. The way to define an Application Scope Environment Entry is to deploy the application in ear package first and second to modify the application.xml as the following (add it inside <application> tag).

<env-entry>
<env-entry-name>java:app/env/value1</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>"Feel Good!"</env-entry-value>
</env-entry>


To get a reference to this Environment Entry, use Dependency Injection or JNDI lookup like this;

@Resource(name="java:app/env/value1")
private String value;

Or

String value = new InitialContext().lookup("java:app/env/value1").toString();

The same mechanism can be held to define Application Server Scope Environment Entry but with a simple change. Instead of java:app place java:global

Regards
Youness
[Message sent by forum member 'youness_teimoury']

http://forums.java.net/jive/thread.jspa?messageID=396139