Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Numerous questions on JNDI

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic