File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question from 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 "Question from" Watch "Question from" New topic

Question from

Li Xin
Ranch Hand

Joined: Feb 06, 2004
Posts: 37
Here is a question from
Which of the following statements regarding an enterprise bean's environment are correct?
1. The container provides the tools that allow the deployer to create and manage the enterprise bean's environment.
2. Enterprise bean instances can modify the values of the environment entries at runtime.
3. The deployer sets and modifies the values of the environment entries by editing the enterprise bean's deployment descriptor.
4. Enterprise bean instances obtain the values of the environment entries from the enterprise bean's deployment descriptor.
5. Enterprise bean instances use the JNDI interfaces to obtain the values of the environment entries.
The provided answer is 1 and 5, it says:
Answers 3 and 4 are incorrect because the deployment descriptor is used to define only the environment entries, as opposed to the values that the enterprise bean expects to be provided at runtime.
I am not sure what it means, why cannot we set and modify the values of the env entry?
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
Environment entries are designed to be deploy-time constants. They are not supposed to be deploy time variable initialization values. When you deploy your application and it has an <env-entry> in its deployment descriptor, the value is taken from the DD and put into the container's naming service to be looked up later. Thus, the value that you originally set your environment entry to is in your deployment descriptor AND in your naming service. If your ejb allowed you to modify an environment entry through your code, then the deployment descriptor env-entry value would not match the actual value that the bean would be looking up. Also, simply changing the value in the DD won't do anything unless you redeploy your application.
Finally, the env-entry tag is for defining a constant that all instances of your bean type will use, like a static constant. If you allowed an instance to alter this value, the new value would be instance specific and not for the whole class to access. If you want something that varies, use instance variables or database record lookups and not env-entry.

Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
Jack Zhou
Ranch Hand

Joined: Dec 27, 2003
Posts: 93
At first look I would select 3 and 4 are both correct. But I would agree that the 3 and 4 are wrong if I look at this the question is about the run-time behaviour.
Yes, the values is specified in the dd before it is depolyed and values are allowed to change before it is deployed. However after it is deployed DD Every thing in dd are transfered to JNDI context. DD is not in the picturre. Only look at this way, I will agree 3 and 4 are wrong. I wish there are less such question in the exam.

Thanks,<br />Jack Zhou<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS,SCEA
I agree. Here's the link:
subject: Question from
It's not a secret anymore!