Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Questions on Declaration of Simple Environment Entries in the Deployment Descriptor

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Source: EJB 3.1 Specification


16.4.1.3 Declaration of Simple Environment Entries in the Deployment Descriptor

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



Here,the element is env-entry-value.
Question 1.If this element is not specified,then How can explicit lookups of the named resource will fail ? Can someone provide example or refer to a resource explaining the same

16.4.4 Container Provider Responsibility

Implement the java:comp/envenvironment naming context, and provide it to the enter-prise bean instances at runtime. The naming context must include all the environment entries
declared by the Bean Provider, with their values supplied in the deployment descriptor or set
by the Deployer. The environment naming context must allow the Deployer to create subcon-texts if they are needed by an enterprise bean.



Question 2:How can the Deployer to create subcon-texts ?Can someone provide example or refer to a resource explaining the same
 
Creator of Enthuware JWS+ V6
Posts: 3390
311
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mohit,

Question 1.If this element is not specified,then How can explicit lookups of the named resource will fail ? Can someone provide example or refer to a resource explaining the same



What they mean is that if the <env-entry-value> is not in the ejb-jar.xml, there won't be an entry in the beans environment. So when you lookup the entry explicitly (by context.lookup()) it will fail.
Maybe an example is better:

My ejb.jar.xml
My bean:


Question 2:How can the Deployer to create subcontexts ?Can someone provide example or refer to a resource explaining the same


A little bit earlier in the specs you will find the hint:

The EJB specification recommends, but does not require, that all references to other enterprise beans be organized in the ejb subcontext of the bean's environment (i.e., in the java:comp/env/ejb JNDI context). Note that enterprise bean references declared by means of annotations will not, by default, be in any subcontext.


So the subcontext is just a sort of subdirectory.

If you follow the recommendations you will name all the ejb references like "ejb/xxx" and with that you have created your subcontext "ejb".
For example:

Regards,
Frits
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic