My RMI Server stops after 60 seconds
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, December 11, 2008 11:45 AM

Hi, I'm using this code to launch a rmi server but if I don't connect a client in the first minute, it shutdowns. I looked for the property to set this timeout time but didn't found it. Thx in advance for any help regarding this problem :) public static void main(String args[]) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { ProxyImpl obj = new ProxyImpl(); Proxy stub = (Proxy) UnicastRemoteObject.exportObject(obj, 0); // Bind the remote object's stub in the registry Registry registry = LocateRegistry.createRegistry(2001); registry.rebind("Serveur", stub);    More>>

Hi,

I'm using this code to launch a rmi server but if I don't connect a client in the first minute, it shutdowns.
I looked for the property to set this timeout time but didn't found it.

Thx in advance for any help regarding this problem :)

			
public static void main(String args[]) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}

try {
ProxyImpl obj = new ProxyImpl();
Proxy stub = (Proxy) UnicastRemoteObject.exportObject(obj, 0);

// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.createRegistry(2001);
registry.rebind("Serveur", stub);

System.err.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}

}
   <<Less

Re: My RMI Server stops after 60 seconds

Posted By:   Edward_Harned  
Posted On:   Monday, December 15, 2008 10:14 AM

Your objects are being garbage collected and your main method is exiting.

Save your impl objects as Class objects (outside the main()) and put a never-ending wait() inside the main().





Object forever = new Object();

// lock object
synchronized (forever) {

try {
// wait forever
forever.wait();

} // end-try

catch (InterruptedException e) {
} // end-catch
} // end-sync

About | Sitemap | Contact