rmiregistry: Port already in use error
843793Aug 22 2001 — edited Jun 27 2004Hi,
I'm running the following comand to start a registry service listening on port 1099. I'll start and stop it several times with control-C and everything will work fine but if I do this a few times, it will get to the point that when I try to start it again I get a message
saying the port is already in use(but I killed the service). Is there a way to start and stop the rmiregistry several times without it getting hung? I'm sure if you get into a production issue with this you need a way to get around it? Besides using the proper command, what can you do to free up a port? Note, I also noticed that netstat shows multiple entries listening on port 1099! Was this from re-trying the command when it failed or from the times that it was successful? Any help appreciated.
Thanks,
Peter
C:\>rmiregistry -J-Djava.security.policy=C:\jdk1.3.0_02\jre\lib\security\pkjava2.policy
java.rmi.server.ExportException: Port already in use: 1099; nested exception
is:
java.net.BindException: Address in use: JVM_Bind
java.net.BindException: Address in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:408)
at java.net.ServerSocket.<init>(ServerSocket.java:173)
at java.net.ServerSocket.<init>(ServerSocket.java:85)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:30)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:312)
at
sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:559)
at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:200)
at
sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:172)
at
sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:319)
at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:119)
at
sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:125)
at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:95)
at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:81)
at sun.rmi.registry.RegistryImpl.main(RegistryImpl.java:320)
C:\>netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP reminetopk:135 0.0.0.0:0 LISTENING
TCP reminetopk:135 0.0.0.0:0 LISTENING
TCP reminetopk:1028 0.0.0.0:0 LISTENING
TCP reminetopk:1030 0.0.0.0:0 LISTENING
TCP reminetopk:1032 0.0.0.0:0 LISTENING
TCP reminetopk:1033 0.0.0.0:0 LISTENING
TCP reminetopk:1099 0.0.0.0:0 LISTENING
TCP reminetopk:1099 0.0.0.0:0 LISTENING
TCP reminetopk:1099 0.0.0.0:0 LISTENING
TCP reminetopk:1409 0.0.0.0:0 LISTENING
TCP reminetopk:1893 0.0.0.0:0 LISTENING
TCP reminetopk:1972 0.0.0.0:0 LISTENING
TCP reminetopk:2026 0.0.0.0:0 LISTENING
TCP reminetopk:2359 0.0.0.0:0 LISTENING
TCP reminetopk:2367 0.0.0.0:0 LISTENING
TCP reminetopk:2369 0.0.0.0:0 LISTENING
TCP reminetopk:7318 0.0.0.0:0 LISTENING
TCP reminetopk:8082 0.0.0.0:0 LISTENING