This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question about the JNDI naming rules 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 about the JNDI naming rules" Watch "Question about the JNDI naming rules" New topic

Question about the JNDI naming rules

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361

According to the EJB Study guide by MZ, when the @Resource annotation is used, it is relative to the java:comp/env naming context.

For example :
@Resource(name="db") DataSource;

The container will search in the JNDI registry for the name : java:comp/env/db

When I tried to create such a resource with the name : java:comp/env/db, I received an error that says the JNDI name I provided is not a valid JNDI name.

This happend on Glassfish application server that ships with Netbeans 6.0

Why does this happen ???

Life is the biggest school
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
Hi Khaled Mahmoud,

I've just test the same thing in my OC4J.

The steps were:
- Deploy the application in OC4J
- Create the DataSource in OC4J Console with:

- Restart the application

And it worked.
I think that, in my console OC4J, the JNDI locations are relative to java:comp/env.

Hope it helps,


SCJP5 | SCBCD5 | SCEA5 Part 1
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Does anybody know why the name start with java:comp is not accepted in the Glassfish application server.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Question about the JNDI naming rules
It's not a secret anymore!