I've followed the various remote JNDI threads to work out how
to get a stand alone java application to connect with a J2EE
RI v1.2.1 server on a remote machine.
I've had success with specifying the remote server host on the
commandline as "-Dorg.omg.CORBA.ORBInitialHost=server1".
As I need to connect to a couple of servers on different machines
I've tried hard coding this into the client application with
System.setProperty("org.omg.CORBA.ORBInitialHost", "server1");
This worked as expected, but when I then tried changing this
property and instantiating another InitialContext with the empty
constructor I could only do lookups on the first host. ie
System.setProperty("org.omg.CORBA.ORBInitialHost", "server1");
Context initial1 = new InitialContext();
// get some beans and do some stuff... then,
System.setProperty("org.omg.CORBA.ORBInitialHost", "server2");
Context initial2 = new InitialContext();
// initial2 now seems to be referencing server1 rather than
// server2 as expected.
My guess is that the client side ORB is getting bound to server1
as a side effect of the first InitialContext() call.
(As I'm making some J2EE server modifications I'd appreciate hearing
the details of what exactly is happening here.)
Since that experiment didn't work I turned to using the InitialContext
constructor which takes an environment as its argument, hoping this
approach will avoid the problems above. This is where I've run into
difficulty. I'm using the following in my client:
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");
env.setProperty(Context.PROVIDER_URL, "iiop://server1:1050");
try {
Context initial = new InitialContext(env);
Object objref = initial.lookup("TestApp/StatelessTest");
StatelessTestHome home =
(StatelessTestHome)PortableRemoteObject.narrow(objref,
StatelessTestHome.class);
StatelessTest slTestRef = home.create();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
Which completes the JNDI lookup without a hitch and narrows the EJBHome,
but then raises the following exception on the home.create() call
CORBA NO_IMPLEMENT 0 No; nested exception is:
org.omg.CORBA.NO_IMPLEMENT: minor code: 0 completed: No
java.rmi.RemoteException: CORBA NO_IMPLEMENT 0 No; nested exception is:
org.omg.CORBA.NO_IMPLEMENT: minor code: 0 completed: No
org.omg.CORBA.NO_IMPLEMENT: minor code: 0 completed: No
at org.omg.CORBA.portable.Delegate.releaseReply(Delegate.java, Compiled
Code)
at org.omg.CORBA.portable.ObjectImpl._releaseReply(ObjectImpl.java,
Compiled Code)
at statelesstest._StatelessTestHome_Stub.create(Unknown Source)
at Client.main(Client.java, Compiled Code)
Caught an unexpected exception!
null
java.lang.NullPointerException
at Client.main(Client.java, Compiled Code)
Any suggestions as to what is causing this would be appreciated. As would
comments on whether specifying the env in the InitialContext constructor
will allow me to access multiple JNDI servers.
thanks,
Michael Richmond
----
Michael Richmond
Information and Communication Sciences e-mail: [EMAIL PROTECTED]
Macquarie University, Australia phone: (+61 2) 9850 6346
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".