ExportException - Port Already in Use
843793May 2 2003 — edited May 13 2003Hi
I know this has been posted before and I have looked at all the other postings that I have been able to find on the forum but I am still baffled by this error which is produced when I have tried to run a remote server program on a Sparc machine
This is the error
java.rmi.server.ExportException: Port already in use: 1099; nested exception is:
java.net.BindException: Address already in use
at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:243)
at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:178
)
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:382) at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:116)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:14
5) at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:92)
at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:78)
at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:1
64) at uk.gov.kirklees.feederctrl.process.FeederImpl.registerToRegistry(Unkn
own source)
at uk.gov.kirklees.feederctrl.process.FeederImpl.main(Unknown Source)
Caused by: java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:321)
at java.net.ServerSocket.bind(ServerSocket.java:308)
at java.net.ServerSocket.bind(ServerSocket.java:266)
at java.net.ServerSocket.<init>(ServerSocket.java:182)
at java.net.ServerSocket.<init>(ServerSocket.java:94)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMI
DirectSocketFactory.java:27) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMI
MasterSocketFactory.java:306) at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:61
5) at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:231)
... 9 more
The code that I have used to generate the call to create the registry was generated from the Sun ONE studio and is a standard template for creating the code which looks like this
public static void registerToRegistry(String name, Remote obj, boolean create) throws RemoteException, MalformedURLException{
if (name == null) throw new IllegalArgumentException("registration name can not be null");
try {
Naming.rebind(name, obj);
} catch (RemoteException ex){
if (create) {
Registry r = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
r.rebind(name, obj);
}else throw ex;
}
}
What puzzles me is that from within the IDE when this class is started I do not get the same error.
The service started OK the first time I used it after invoking the rmiregistry command.
Subsequent attempts to start it fail with the error. I have checked the running processes on the server prior to restarting the rmiregistry and there appears to be no process running. I start the rmi registry and the process is there under netstat -a but the call to start the serverprogram falls over.
Any ideas on this would be gratefully recieved as I am really puzzled by this one