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 Question about the JNDI naming rules 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 "Question about the JNDI naming rules" Watch "Question about the JNDI naming rules" New topic
Author

Question about the JNDI naming rules

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Hi,

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 ???






SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
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,

Beno�t


SCJP5 | SCBCD5 | SCEA5 Part 1
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Hi,
Does anybody know why the name start with java:comp is not accepted in the Glassfish application server.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Question about the JNDI naming rules
 
Similar Threads
URGENT Please!!! JNDI Naming :)
cant i look up datasource connection using environment variables
Lookup strings question
@Resource and JNDI name
Finding resources