aspose file tools*
The moose likes Websphere and the fly likes JNDI Lookup Error in Websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "JNDI Lookup Error in Websphere" Watch "JNDI Lookup Error in Websphere" New topic
Author

JNDI Lookup Error in Websphere

Sankar Tanguturi
Greenhorn

Joined: Feb 18, 2003
Posts: 17
Hi,
I am trying to lookup a datasource from my J2EE application that has 2 jar files and a war file. I have a DataSource defined in Websphere with JNDI name as com/agac/eproposal/DataSource. In Application Assembly Tool (AAT), I defined a reference to it from WAR as Name : jdbc/eproposalDS which is Bound to : com/agac/eproposal/DataSource.
In my servlet, I am trying to look it up as
ds = (DataSource)(new InitialContext().lookup("java:comp/env/jdbc/eproposalDS");
This works on one machine running Websphere Advanced Edition 4.0 on Solaris. But on my local machine running WAE 4.0 on Windows NT, this gives the following error :
javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1443)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:824)
at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1166)
at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1158)
at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1210)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.agac.eproposal.util.JDBCUtil.Init(JDBCUtil.java:155)
at com.agac.eproposal.util.JDBCUtil.GetConnection(JDBCUtil.java:54)
at com.agac.eproposal.util.SystemConfig.Load(SystemConfig.java:263)
at com.agac.eproposal.util.SystemConfig.Get(SystemConfig.java:95)
at com.agac.eproposal.control.EProposal.init(EProposal.java:103)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doInit(ServletManager.java:802)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._init(StrictLifecycleServlet.java:137)
at com.ibm.servlet.engine.webapp.PreInitializedServletState.init(StrictLifecycleServlet.java:243)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.init(StrictLifecycleServlet.java:103)
at com.ibm.servlet.engine.webapp.ServletInstance.init(ServletManager.java:388)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.servlet.engine.webapp.ServletManager.addServlet(ServletManager.java:84)
at com.ibm.servlet.engine.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:226)
at com.ibm.servlet.engine.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:357)
at com.ibm.servlet.engine.webapp.WebApp.loadServletManager(WebApp.java:1001)
at com.ibm.servlet.engine.webapp.WebApp.init(WebApp.java:133)
at com.ibm.servlet.engine.srt.WebGroup.loadWebApp(WebGroup.java:234)
at com.ibm.servlet.engine.srt.WebGroup.init(WebGroup.java:139)
at com.ibm.servlet.engine.ServletEngine.addWebApplication(ServletEngine.java:633)
at com.ibm.ws.runtime.WebContainer.install(WebContainer.java:36)
at com.ibm.ws.runtime.Server.startModule(Server.java:615)
at com.ibm.ejs.sm.active.ActiveModule.startModule(ActiveModule.java:509)
at com.ibm.ejs.sm.active.ActiveModule.startAction(ActiveModule.java:355)
at com.ibm.ejs.sm.active.ActiveObject.startObject(ActiveObject.java:709)
at com.ibm.ejs.sm.active.ActiveObject.start(ActiveObject.java:131)
at com.ibm.ejs.sm.active.ActiveObject.operateOnContainedObjects(ActiveObject.java:609)
at com.ibm.ejs.sm.active.ActiveEJBServer.startAction(ActiveEJBServer.java:730)
at com.ibm.ejs.sm.active.ActiveObject.startObject(ActiveObject.java:709)
at com.ibm.ejs.sm.active.ActiveObject.start(ActiveObject.java:131)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.ejs.sm.agent.AdminAgentImpl.activeObjectInvocation(AdminAgentImpl.java:93)
at com.ibm.ejs.sm.agent.AdminAgentImpl.invokeActiveObject(AdminAgentImpl.java:62)
at com.ibm.ejs.sm.agent._AdminAgentImpl_Tie._invoke(_AdminAgentImpl_Tie.java:80)
at com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(ExtendedServerDelegate.java:506)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:2294)
at com.ibm.CORBA.iiop.OrbWorker.run(OrbWorker.java:185)
at com.ibm.ejs.oa.pool.ThreadPool$PooledWorker.run(ThreadPool.java:95)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122).
Also, if I change the lookup code to
ds = (DataSource)(new InitialContext().lookup("com/agac/eproposal/DataSource"); there are no errors.
I did not notice any differences in the settings for the two installations. The ear on both the machines is same. Any help is appreciated.
Thanks,
Sankar
sankara_tanguturi@yahoo.com
Patrick Finnegan
Ranch Hand

Joined: Mar 05, 2002
Posts: 179
Try using the WebSphere dunpnamespace utility to list the JNDI names in the name space and see if they match the lookup.
Sankar Tanguturi
Greenhorn

Joined: Feb 18, 2003
Posts: 17
I did a dump of namespace on unix as well as my local NT machine. The relevant entries seem to be identical. Like I mentioned earlier,looking up with the data source reference works on Unix installation but not the one on NT.
Balbir Singh
Ranch Hand

Joined: Jun 01, 2001
Posts: 79
Please make sure that JAVA_HOME is pointing to WebSphere's JDK. We had faced a similar problem on NT since our JAVA_HOME was pointing to Weblogic's JDK. After rectifing it, things started working. Hope it helps !!!


Thanks and Regards<br />Balbir Singh<br />Sun Certified Java Programmer<br />IBM Certified Administrator for WebSphere4.0
Sankar Tanguturi
Greenhorn

Joined: Feb 18, 2003
Posts: 17
Hi,
I did have my JAVA_HOME pointing to sun JDK, which I changed to point to Websphere's JDK. That did not help. I also noticed in the log the following error which seems to say that the bindings were not loaded.
[03.02.20 16:56:28:861 EST] 3d1326d8 ServletEngine A SRVE0169I: Loading Web Module: <null>.
[03.02.20 16:56:29:071 EST] 3d1326d8 WebApp X SRVE0142E: Failed to load WebApp Bindings javax.naming.InvalidNameException: Null names are not allowed.
at com.ibm.ws.naming.util.WsnName.setName(WsnName.java:930)
at com.ibm.ws.naming.util.WsnName.<init>(WsnName.java:184)
at com.ibm.ws.naming.util.WsnNameParser.parse(WsnNameParser.java:96)
at com.ibm.servlet.engine.webapp.WebApp.createContextsAndRebind(WebApp.java:895)
at com.ibm.servlet.engine.webapp.WebApp.populateJavaNameSpace(WebApp.java:842)
at com.ibm.servlet.engine.webapp.WebApp.init(WebApp.java:125)
at com.ibm.servlet.engine.srt.WebGroup.loadWebApp(WebGroup.java:234)
at com.ibm.servlet.engine.srt.WebGroup.init(WebGroup.java:139)
at com.ibm.servlet.engine.ServletEngine.addWebApplication(ServletEngine.java:633)
at com.ibm.ws.runtime.WebContainer.install(WebContainer.java:36)
at com.ibm.ws.runtime.Server.startModule(Server.java:615)
at com.ibm.ejs.sm.active.ActiveModule.startModule(ActiveModule.java:509)
at com.ibm.ejs.sm.active.ActiveModule.startAction(ActiveModule.java:355)
at com.ibm.ejs.sm.active.ActiveObject.startObject(ActiveObject.java:709)
at com.ibm.ejs.sm.active.ActiveObject.start(ActiveObject.java:131)
at com.ibm.ejs.sm.active.ActiveObject.operateOnContainedObjects(ActiveObject.java:609)
at com.ibm.ejs.sm.active.ActiveEJBServer.startAction(ActiveEJBServer.java:730)
at com.ibm.ejs.sm.active.ActiveObject.startObject(ActiveObject.java:709)
at com.ibm.ejs.sm.active.ActiveObject.start(ActiveObject.java:131)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.ejs.sm.agent.AdminAgentImpl.activeObjectInvocation(AdminAgentImpl.java:93)
at com.ibm.ejs.sm.agent.AdminAgentImpl.invokeActiveObject(AdminAgentImpl.java:62)
at com.ibm.ejs.sm.agent._AdminAgentImpl_Tie._invoke(_AdminAgentImpl_Tie.java:80)
at com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(ExtendedServerDelegate.java:506)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:2294)
at com.ibm.CORBA.iiop.OrbWorker.run(OrbWorker.java:185)
at com.ibm.ejs.oa.pool.ThreadPool$PooledWorker.run(ThreadPool.java:95)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122)
-Sankar
Tony Chen
Ranch Hand

Joined: Jan 29, 2001
Posts: 286
try this:
ds = (DataSource)(new InitialContext().lookup("jdbc/eproposalDS");


SCJP Java 2 - IBM Certified Enterprise Developer - WebSphere V4.0 & V5.0 - IBM Certified System Administrator - WebSphere Network Deployment V6.0 - Canadian Securities Course (CSC) Certification
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JNDI Lookup Error in Websphere