 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Petar Guest
|
Posted: Sun Sep 14, 2003 8:13 am Post subject: RMI - Naming:lookup & rebind conflict |
|
|
Hi,
I have problem that rebind fails after calling lookup. Why, and what to do
in the between to prevent this from happening. More deails follows.
Thanks.
====DETAILS===
RMI server needs to know if there is an instance already running. If not it
continues witn binding. Here is how I do it.
try {
IIMServer oldServer =
(IIMServer)Naming.lookup("//localhost:1099/applications/XYServer/IMSERVER");
if (oldServer.ping()) {
System.out.println("Server already running. Bye.");
System.exit(-1);
}
} catch (Exception e) {
System.out.println("no old server.");
}
This above part works fine. However the following does fail and the flow
turns into
the exception and finally exits with -1.
System.setSecurityManager(new RMISecurityManager());
URL url = ClassLoader.getSystemResource("classes"); // app's root dir
must be in classpath !!
System.setProperty("java.rmi.server.codebase", url.toString()+"/");
try {
Naming.rebind("//localhost:1099/applications/XYServer/IMSERVER",
this);
} catch (Exception e) {
e.printStackTrace();
System.exit( -1);
}
System.out.println("Server created.");
It is fascinating that if I remove first part of code (which seeks for old
instance of server)
the second part works perfectly. (btw: policy and codebase are set nicely
and properly).
Why does that happen ? I am astonished. If anyone had this problem please
let me know the solution.
Kindest regards
Petar.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|