wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes query related to declaration of simple environment entries in the DD? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "query related to declaration of simple environment entries in the DD?" Watch "query related to declaration of simple environment entries in the DD?" New topic
Author

query related to declaration of simple environment entries in the DD?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

from section 16.4.1.3 of ejb3.1 specs it says that :

Each env-entry deployment descriptor element describes a single environment entry. The env-entry element consists of an optional description of the environment entry, the environment entry name relative to the java:comp/env context, the expected Java type of the environment entry value (i.e., the type of the object returned from the EJBContext or JNDI lookup method), and an optional environment entry value.

how can be the environment entry value be optional ? isn't it the most important part regarding environment entries , that is, to bind a jndi name with a value. what use is a name without a value ? Please help.
Sorry for posting many questions about ENC but I have not been very comfortable with this topic right from the starting.
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

again got the answer after reading few more pages down there in the specs.
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

So what is your conclusion?


Regards,
Prajakta
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

quoting directly from the specs

To support this case, the container must only inject a value for the environment entry if the application assembler or deployer has specified a value to override the default value. The env-entry-value element in the deployment descriptor is optional when an injection target is specified. If the element is not specified, no value will be injected. In addition, if the element is not specified, the named resource is not initialized in the naming context, and explicit lookups of the named resource will fail.


so if you haven't specified <env-entry-value> then since there is no value no injection will be performed either by @Resource annotation or <injection-target>. in this case the field will be initialized to default value or whatever you have specified. also if you haven't specified <env-entry-value> then the resource you named in <env-entry-name> wont be initialized. that means if you try to do lookup using EJBContext or JNDI lookup you will get EJBException caused by NameNotFoundException since there wont be any binding object to the name that you specified
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138


Ok, got it, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: query related to declaration of simple environment entries in the DD?
 
Similar Threads
How do you access [env-entry] values in web.xml from Java code?
ordering of env-entry sub elements
Environment variable
JNDI access to J2EE components
How to create an environmental entry in WLS?