• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JNDI Lookup from Java Client not working

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I successfully performed a lookup using the InitialContext from a Java client after setting all the properties to obtain the context for the conatiner in the locally running Oracle JDeveloper IDE.
Following were the properties:
However, once I ported the application to Oracle 9iAS and changed the PROVIDER_URL to -
PROVIDER_URL=ormi://<server ip>:23791/appname
all jndi lookups fail, whether to call a method on some ejb or to obtain a datasource. My client is a Java client invoked from a batch file. DataSource name in the Application server is given as "DIS" - which translates to "jdbc/DISDS" while performing lookups. Here's the code for the client which tries to get the datasource:
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
props.put(Context.SECURITY_PRINCIPAL, "admin");
props.put(Context.SECURITY_CREDENTIALS, "welcome");
props.put(Context.PROVIDER_URL, "ormi://");
Context ctx = new InitialContext(props);
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/DISDS");
I get the following exception on the line where the lookup is performed:
java.net.ConnectException: Connection refused.
What am I doing wrong?
Thanks, Rohit
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have more information such as a stack trace?
Rohit Lal
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stack trace though not aailable right now, was basically pointing to the line which had the lookup. "Connection refused" was part of the message in the trace. Howeer, we got the problem- it was the rmi.xml file which forms part of the configuration files for OC4J. It needed the IP, security principal (user name) and credentials (password).
<?xml version = '1.0' standalone = 'yes'?>
<!DOCTYPE rmi-server PUBLIC "Orion RMI-server" "http://xmlns.oracle.com/ias/dtds/rmi-server.dtd">
<rmi-server port="23891">
<!-- A remote server connection example -->
<!-- <server host="the.remote.server.com" username="adminUser" password="123abc" /> -->
<!-- path to the log-file where RMI-events/errors are stored -->
<file path="log/rmi.log"/>
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!