aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Numerous questions on JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Numerous questions on JNDI" Watch "Numerous questions on JNDI" New topic
Author

Numerous questions on JNDI

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 199
Howdy ranchers,

I've a lot of questions related to JNDI resources in Java EE and Java SE. Some of them might me novice but please answer them as I am a bit confused. So, here I go...

1. What is Java:comp/env exactly? Is it related to Java EE only? For example, I create a JNDI data source named jdbc/sqlSource in, say, glassfish so I would typically access that DS in a web app deployed in glassfish. How about trying to access this DS from a desktop application ? How can I access this data source from a stand alone java SE client?

2. I've heard about Global JNDI Namespace. What is that and does it vary from one app server to another? I mean to say, does every app server has got its own global JNDI namespace?Is it right to say that the objects registered under a Global JNDI namespace can be accessed from code running in another JVM?

3. I recently saw some examples using java:app, java:comp, and java:global. What is the relation of these three with java:comp?

Well, enough for now. I'll post more if I run into more confusion.


Thanks and Regards,
Girish
Kai Wähner
Ranch Hand

Joined: Sep 16, 2009
Posts: 76
1. What is Java:comp/env exactly? Is it related to Java EE only? For example, I create a JNDI data source named jdbc/sqlSource in, say, glassfish so I would typically access that DS in a web app deployed in glassfish. How about trying to access this DS from a desktop application ? How can I access this data source from a stand alone java SE client?



No, it is not related to JEE only, JNDI is also used in JSE. So you can also access the ressource from a desktop application.
JNDI is a service to lookup objects through keys. Each ressource (JDBC, LDAP, JMS and so on) has an own Factory to create a InitialContext - but all use the same interface.

You can either use an application client of glassfish or make a JNDI lookup (you have to enter url, port andd soon) and create a new InitialContext.


2. I've heard about Global JNDI Namespace. What is that and does it vary from one app server to another? I mean to say, does every app server has got its own global JNDI namespace?Is it right to say that the objects registered under a Global JNDI namespace can be accessed from code running in another JVM?


At the moment, every application server uses its own JNDI prefix, e.g. java:com/env.

JEE6 introduces a global JNDI prefix, e.g. for EJBs. So with JEE6, you can develope EJBs and other ressources once and deploy them on every JEE6-AppServer. With JEE5, the migration was more difficult, because there was no global JNDI namespace.

3. I recently saw some examples using java:app, java:comp, and java:global. What is the relation of these three with java:comp?


It looks like different JNDI namespaces, maybe from different application servers.
You can use an arbitrary JNDI name I think (I am not sure for this), but you have to know and use this same name, when you make a JNDI lookup from the client.


Hope this helps...


My IT-blog about my experiences with: Java / JEE, IT Conferences and IT Certifications

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Numerous questions on JNDI