• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet to db connection using JNDI

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to connect to an Oracle database from a servlet using a JNDI lookup and the DataSource interface.
The code I use is :

where "tisdev" is the name of the database.
This gives the following error:
javax.naming.NameNotFoundException:Missing node [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound]
How do I fix?
I've tried various strings in the lookup method, all with similar results.
I'm using JBuilder3.5 & Inprise App Server 4.0, (though my understanding is that none of my code runs on the app server?)Running the same code under iPlanet 6.0 works fine. Connecting via an EJB under Inprise also works fine. What am I missing?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have exactly same problem when I do lookout for Datasource.I am doing lookup as follows and am getting follwoing errors. I would be greatful if you can share your solution(if you found out) with me.
Context env = (Context) context.lookup("java:comp/env");
dataSource = ( DataSource )context.lookup("java:comp/env/jdbc/ssiDataSource");
javax.naming.NameNotFoundException: Missing Node - ssiDataSource
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:511)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:974)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:979)
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ian and Madhu,
JNDI (as the name suggests) is an interface. Therefore it requires an implementation. And you need to register a lookup name with the implementation before a client can use that lookup name.
For example, I use a J2EE application server called OC4J (Oracle Container for J2EE). It has a JNDI implementation. When I start up this application server, it reads an XML (configuration) file that contains the lookup name for an Oracle datasource. It then registers that name with its JNDI implementation (also know as a "driver"). So after I start up OC4J, I can use code (similar to yours) in my client to obtain the datasource.
Now, what JNDI driver are you using, and how do you register the lookup name with that driver?
Hope this helps.
Good Luck,
Avi.
 
Ian Whitelaw
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow! A response after nearly two and a half years!
Not surprisingly, I'm afraid I cannot remember the original problem too well, nor whether I ever found a solution. All I do remember is that the whole thing was very frustrating, that most people don't know what they're talking about most of the time, and that people's propensity for expressing an opinion is usually inversely proportional to the insight gained by the expression of that opinion (JavaRanch contributors excepted). Now that I'm the wrong side of forty (and therefore in the eyes of most corporate HR departments/IT managers/employment agencies far too old to learn anything new), I'm hoping to give up the whole IT malarky and emigrate to New Zealand to throw pots and sell them to the tourist hoardes looking to find Isengard or Edoras or any one of the innumerable Lord of the Rings sites. In the meantime, I'd better get back to supporting the dodgy piece of PL/SQL code written by some contractor who's long since left and is now fitting windows in Peterborough.
Anyway, good luck solving your problem. There's plenty of good stuff on the Ranch if you've time to look.
Ian
P.S. For non-UK readers and the geographically-challenged, the Peterborough in question is a (rather anonymous) town in SE England about an hour north of London by train.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avi,
I am using Oracle AS 10g. I am trying to use the "DataSourceUserManager" provided with it. I configured this to be the user manager for my app, and and set all initialization params (of which datasource is one). When I try to go to the security section of my app thru OEM, I get a NamingException that the JNDI name for the datasource could not be found. When I looked at the logs, I got the follg. message:
Error instantiating application at file:/usr/oracle/infra/j2ee/OC4J_SECURITY/applications/B2B_Demo_App.ear: Error initializing
userManager 'com.evermind.sql.DataSourceUserManager': NamingException: Need to specify class name in environment or system property, or
as an applet parameter, or in an application resource file: java.naming.factory.initial
What could be the problem? I thought all I need to do was to configure a data source and provide it to the DataSourceUserManager. OC4J doesn't seem to be storing and retrieving the JNDI name. Or am I missing something? Any help is appreciated. Thanks.

Originally posted by Avi Abrami:
Hi Ian and Madhu,
JNDI (as the name suggests) is an interface. Therefore it requires an implementation. And you need to register a lookup name with the implementation before a client can use that lookup name.
For example, I use a J2EE application server called OC4J (Oracle Container for J2EE). It has a JNDI implementation. When I start up this application server, it reads an XML (configuration) file that contains the lookup name for an Oracle datasource. It then registers that name with its JNDI implementation (also know as a "driver"). So after I start up OC4J, I can use code (similar to yours) in my client to obtain the datasource.
Now, what JNDI driver are you using, and how do you register the lookup name with that driver?
Hope this helps.
Good Luck,
Avi.


 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic