JMX agent throws java.net.MalformedURLException when host name is set to all numeric value

centos, hostname, jmx, malformedurlexception, tomcat

Solution

I had also the same problem, but I found out: The reason is that tomcat tries to bind to an IP so it does not use localhost, but your hostname. In my case: SUSEDesktop. So I had to add a hosts entry to /etc/hosts:

127.0.0.1    SUSEDesktop
::1          SUSEDesktop

Replace SUSEDesktop with the host name of your computer, you can find it out with: `uname -n`

Problem

We are using tomcat 7.0.27 in our application. We are below setting jmx properties on tomcat startup. -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8666 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false If the centOS server hostname on which this tomcat is running is set to all numeric value like 005056940096, tomcat does not start. It gives below exception. Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: 005056940096: 005056940096 Server is running on centOS6. If hostname is set to non numeric value, it works properly. I tried setting hostname in /etc/hosts and /etc/sysconfig/network, it still does not work. I also tried setting below property to server ip address, still it does not work. -Djava.rmi.server.hostname=${IP} Please let me know if you have come across any such issue. Thanks.

Original source