• 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
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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: 3386
309
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
 
A teeny tiny vulgar attempt to get you to buy our stuff
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic