Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about the JNDI naming rules

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ???




 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anybody know why the name start with java:comp is not accepted in the Glassfish application server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic