{"id":1887,"date":"2022-08-30T15:20:16","date_gmt":"2022-08-30T15:20:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/has-locateregistry-createregistryint-port-changed-in-java-1-7-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:16","modified_gmt":"2022-08-30T15:20:16","slug":"has-locateregistry-createregistryint-port-changed-in-java-1-7-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/has-locateregistry-createregistryint-port-changed-in-java-1-7-collection-of-common-programming-errors\/","title":{"rendered":"Has LocateRegistry.createRegistry(int port) changed in java 1.7?-Collection of common programming errors"},"content":{"rendered":"<li>\n<p>The bigger question is, while this runs fine on java 1.6 (each subsequent server on a host uses the next available port, since LocateRegistry.createRegistry(i) throws an exception if the port is unavailable), not so on 1.7. As a result, we get the following exception when the second server attempts to JMXConnectorServer.start(). Does anyone know if the behavior changed for createRegistry? If so, is there something else we should do?<\/p>\n<pre><code>2013-02-07 15:34:28,451 INFO  [main] Using JMX port: 9500\n2013-02-07 15:34:28,929 ERROR [main] Unable to register MBean with JMX\njava.io.IOException: Cannot bind to URL [rmi:\/\/:9500\/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]\n        at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServe.java:826)\nat javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:431)\nat com.theatre.services.framework.AbstractService.run(AbstractService.java:306)\nat com.theatre.services.reporttree.TreeServerImpl.run(TreeServerImpl.java:690)\nat com.theatre.services.framework.Launcher.main(Launcher.java:99)\nCaused by: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]\nat com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:139)\nat com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:226)\nat javax.naming.InitialContext.bind(InitialContext.java:419)\nat javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:643)\nat javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:426)\n... 3 more\nCaused by: java.rmi.AlreadyBoundException: jmxrmi\nat sun.rmi.registry.RegistryImpl.bind(RegistryImpl.java:131)\nat sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)\nat sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:390)\nat sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:248)\nat sun.rmi.transport.Transport$1.run(Transport.java:159)\nat java.security.AccessController.doPrivileged(Native Method)\nat sun.rmi.transport.Transport.serviceCall(Transport.java:155)\nat sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)\nat sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)\nat sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)\nat java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\nat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\nat java.lang.Thread.run(Thread.java:662)\nat sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)\nat sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)\nat sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)\nat sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)\nat com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:137)\n... 7 more\n<\/code><\/pre>\n<\/li>\n<p id=\"rop\"><small>Originally posted 2013-12-02 21:11:27. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>The bigger question is, while this runs fine on java 1.6 (each subsequent server on a host uses the next available port, since LocateRegistry.createRegistry(i) throws an exception if the port is unavailable), not so on 1.7. As a result, we get the following exception when the second server attempts to JMXConnectorServer.start(). Does anyone know if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1887","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1887"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1887\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}