Occasional JMX-Port already in use error
A handful of times during development of a server using JMX, we've seen the following error:
[2007-03-24 13:26:59,489][Level: WARN][Thread:main][Could not detect RMI registry - creatingnew one] - [NDC:]
[2007-03-24 13:26:59,489][Level: INFO][Thread:main][An exception occurred during startup.
[exception:BeanCreationException][reason:Error creating bean with name'registry' defined inclass path
resource [proxyServerContext-jmx.xml]: Invocation of init method failed;
nested exception is *java.rmi.server.ExportException: Port already in use: 5000*; nested exception is:
java.net.BindException: Address already in use: JVM_Bind][stack trace:
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1088)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
...
It's been difficult to reproduce consistently or otherwise, but I'd feel more comfortable if we had some more insight into its possible causes.
The JMX configuration can be found in the post at http://forum.java.sun.com/thread.jspa?threadID=5131562&tstart=60.
BTW, if I simply start two instances of the server, I get a different error
[exception:BeanCreationException][reason
:Error creating bean with name'connectorServer' defined inclass path resource [proxyServerContext-jmx.xml]: Invocation
of init method failed; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:5000/jmxrmi]: javax
.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]
so there is something different going on in the previous case I described...
Any insight would be appreciated.
Regards,
Steve

