• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI Lookup from Java Client not working

 
Rohit Lal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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:
INITIAL_CONTEXT_FACTORY=com.evermind.server.rmi.RMIInitialContextFactory
SECURITY_PRINCIPAL=admin
SECURITY_CREDENTIALS=welcome
PROVIDER_URL=ormi://localhost:23891/current-workspace-app
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://192.100.100.239:23791/DISApplication");
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
 
Ajith Kallambella
Sheriff
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
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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 -->
<log>
<file path="log/rmi.log"/>
</log>
</rmi-server>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!