I installed glassfish server 2.1 on ec2 which has dynamic ip, recently I stopped and restarted server and it got new ip, glassfish is trying to use past address and giving exception how to solve this
Exception:
com.sun.appserv.server.ServerLifecycleException: Cannot bind to URL
[rmi://ip-10-83-110-8.ec2.internal:8686/management/rmi-jmx-connector]:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host:
ip-10-83-110-8.ec2.internal; nested exception is:
java.net.ConnectException: Connection timed out];_RequestID=cdebf524-d038-407c-870e-0947bab80378;|Service
com.sun.enterprise.admin.server.core.JmxConnectorLifecycle@428c6e04
cannot be started! : com.sun.appserv.server.ServerLifecycleException:
Cannot bind to URL
[rmi://ip-10-83-110-8.ec2.internal:8686/management/rmi-jmx-connector]:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host:
ip-10-83-110-8.ec2.internal; nested exception is:
java.net.ConnectException: Connection timed out]|#]
I got the solution, ubuntu is using the dynamic ip assigned by ec2 as hostname and GF opens local socket connections by using as the host what is returned from java.net.InetAddress.getLocalHost() which is returning hostname.
So short answer is we need to change the hostname.