aspose file tools*
The moose likes Servlets and the fly likes How to Bound JNDI names and references Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to Bound JNDI names and references" Watch "How to Bound JNDI names and references" New topic
Author

How to Bound JNDI names and references

Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
Hi Guys,
I'm trying to do a JNDI lookup for my datasource in a servlet(No EJBs) which is being created in Websphere 4.0 enviornment.
I have created the JDBC driver, the datasource and their respective resource properties files. But I keep getting
nullpointer exception. From the Websphere documentation I read that I need to do bound JNDI Names and references. How do I accomplish that, Is it done programmatically ?
Can anybody give any lead on this.
my code is as follows
java.util.Properties parms = new java.util.Properties();
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
javax.naming.Context ctx = new javax.naming.InitialContext(parms);
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/OracleDSN");
Connection Con = ds.getConnection();
Thanks
Neha
chin josei
Greenhorn

Joined: Jun 22, 2001
Posts: 25
Hii..
U need to bind it to the JNDI tree.I have done it for Weblogic.
For Websphere also it might be similar
Herez what I have used.
Hashtable h1 = new Hashtable();
h1.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h1.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context jndictx = new InitialContext(h1);
jndictx.rebind("JNDI Name",this);
Hope this helps
chin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Bound JNDI names and references
 
Similar Threads
Not able to use my datasource using JNDI lookup
Not able to get my Datasource using JNDI Lookup
JNDI Lookup help in websphere 4.0
Not able to access my datasource using JNDI lookup
Not able to perform JNDI lookup