Monday, December 8, 2014

NumberFormatExeption while passing IPV6 in JMX call

Add Square bracket in case of the IPV6 usage

InetAddress inetAddress=InetAddress.getByName(hostIp);
    if(inetAddress instanceof Inet6Address){
        url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://[" +         inetAddress.getHostAddress() + "]:" + port + "/jmxrmi");
    }else {
        url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + inetAddress.getHostAddress() + ":" + port + "/jmxrmi");
}