from section 184.108.40.206 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.
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