Win a copy of Svelte and Sapper in Action this week in the JavaScript 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question from

Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Let me tell you a story about a man named Jed. He made this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic