aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Questions on Declaration of Simple Environment Entries in the Deployment Descriptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Questions on Declaration of Simple Environment Entries in the Deployment Descriptor" Watch "Questions on Declaration of Simple Environment Entries in the Deployment Descriptor" New topic
Author

Questions on Declaration of Simple Environment Entries in the Deployment Descriptor

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1734
    
  25

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Questions on Declaration of Simple Environment Entries in the Deployment Descriptor