This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB3.1 - Environment Naming Context(ENC) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB3.1 - Environment Naming Context(ENC)" Watch "EJB3.1 - Environment Naming Context(ENC)" New topic
Author

EJB3.1 - Environment Naming Context(ENC)

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi,
I'm going through this Enterprise Java Beans 3.pdf (by Frits). I have found few things which might need changing. Not sure, if these are already notified.

Page 6-61

Other Callback methods (@prePassivate, @PostActivate,...), there is no need to mention "(not Singleton)" as these methods are not applicable to Singleton beans.


Page 7-63

The title should have been "7 Injection and Environment Naming Context(ENC)"


Page 7-74
There is a note at the bottom saying-
Note: an entry is only created when both “name” and “lookup” are specified in the @Resource annotation.


I think an entry is also created when there is neither "name" nor "lookup".
java:comp/env/<package-name>.<bean name>/<field name> (for @Resource with no attributes)





Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1627
    
  23

Naren Chivukula wrote:
Page 6-61
Other Callback methods (@prePassivate, @PostActivate,...), there is no need to mention "(not Singleton)" as these methods are not applicable to Singleton beans.

Agree, fixed.

Naren Chivukula wrote:
Page 7-63
The title should have been "7 Injection and Environment Naming Context(ENC)"

Both names (Environment Naming Context, Enterprise Naming Context) are used in the java world, but I agree I should use the name from the specs: Environment Naming Context. Fixed.

Naren Chivukula wrote:
Page 7-74
There is a note at the bottom saying-
Note: an entry is only created when both "name" and "lookup" are specified in the @Resource annotation.

I think an entry is also created when there is neither "name" nor "lookup".
java:comp/env/<package-name>.<bean name>/<field name> (for @Resource with no attributes)

There is no entry created in this case, and an explicit lookup in this case will fail with a javax.naming.NameNotFoundException.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

You are right. But, I was asking in a case where no attribute is provided for @Resource, then also a new entry is created?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1627
    
  23

Do you mean like this (for "init")?

In this case there is no entry created and the lookup in line 6 will fail.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Yes, you are right. That doesn't work.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3.1 - Environment Naming Context(ENC)
 
Similar Threads
Resource injection for env entry in the field
Questions on Declaration of Simple Environment Entries in the Deployment Descriptor
EJB Notes I prepared during my preparation for SCBCD
Sample Petclinic does not display static content
@Resource(name="x",lookup="y")