• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
again got the answer after reading few more pages down there in the specs.
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is your conclusion?
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok, got it, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic