This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Error while trying to get the datasource object using JNDI lookup in WSAD....

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to access the datasource object from a stateless session ejb.
...code follows.
-----------------------
InitialContext ctx = null;
String dsName1 = "jdbc/was3"; // JNDI name
DataSource ds1 = null;
try
{
ctx = new InitialContext();
ds1 = (DataSource)ctx.lookup(dsName1);
} catch(Exception e) {
e.printStackTrace(System.out);
}
It gives errors while running it with the universal test client of WSAD. It is not able to connect to the remote database. It says 'Network Adapter could not establish the connection', eventhough the database access works very well from other java application with Driver Manager implementation of connection. It doesn't work while creating the data source object by looking up the jndi name.
It is giving following error when I try to install the application in WAS 4.0 server also.
Default Server jndiNamingException (com.ibm.ws.naming.util.WsnResourceBundle ��;
com.ibm.ws.naming.urlns.genericURLContextRoot createSubcontext(Name) local: jdbc/jdbc �javax.naming.NameNotFoundException: Name jdbc not found in context "local:".
at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1443)
at com.ibm.ws.naming.ipbase.NameSpace.getParentContext(NameSpace.java:1342)
at com.ibm.ws.naming.urlbase.UrlContext.getParentBindingData(UrlContext.java:1529)
at com.ibm.ws.naming.urlbase.UrlContext.createSubcontext(UrlContext.java:703)
at com.ibm.websphere.naming.JndiHelper.createSubcontexts(JndiHelper.java:261)
at com.ibm.websphere.naming.JndiHelper.createSubcontextsDriver(JndiHelper.java:237)
at com.ibm.websphere.naming.JndiHelper.recursiveBind(JndiHelper.java:499)
at com.ibm.websphere.naming.JndiHelper.recursiveRebind(JndiHelper.java:317)
at com.ibm.ws.runtime.utils.ResourceBinder.bind(ResourceBinder.java:271)
at com.ibm.ws.runtime.utils.ResourceBinder.bind(ResourceBinder.java:212)
at com.ibm.ws.runtime.Server.bindResource(Server.java:827)
at com.ibm.ws.runtime.StandardServer.bindResource(StandardServer.java:451)
at com.ibm.ws.runtime.StandardServer.bindResources(StandardServer.java:444)
at com.ibm.ws.runtime.StandardServer.initializeRuntime0(StandardServer.java:344)
at com.ibm.ws.runtime.Server.initializeRuntime(Server.java:882)
at com.ibm.ws.runtime.StandardServer.main(StandardServer.java:519)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:158)
-------------------------------------------------------------------
Works fine with the local db2 database, but not with the remote oracle database. I had set up the properties in server configuration 'data sources' of WSAD and in JDBC data sources of WAS (while testing on WAS directly) also.
Can anybody help me with this?
Thanks Much.
--
Sailaja
 
Does this tiny ad smell okay to you?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic