Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • 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
Netbeans IDE Fedora Java
  • 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.
 
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is your conclusion?
 
gurpeet singh
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • 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
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok, got it, thanks.
 
Arthur, where are your pants? Check under this tiny ad.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic