Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 459
user3012665 Avatar asked Nov 20 '13 10:11

user3012665


4 Answers

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

like image 74
laserbeamer Avatar answered Nov 16 '22 19:11

laserbeamer


echo "127.0.0.1 $HOSTNAME" | sudo tee -a /etc/hosts

like image 27
Steve Jiang Avatar answered Nov 16 '22 18:11

Steve Jiang


I had the same problem, finally solved by adding "Local" or "local" to /etc/hosts Something like 127.0.0.1 localhost Local local

like image 5
Ramin Mir. Avatar answered Nov 16 '22 18:11

Ramin Mir.


I had a similar problem starting a Spring-Boot app from the Spring Tools Suite on a Mac. It was a download from a Spring MVC / Spring Boot example for SOLR off Github.

The error was something like: java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException:XXXXXXX-221227.this.that.foo.other

By adding these two lines to the /private/etc/hosts file on my Mac the problem went away. No "re-up" of the network interfaces was necessary.

127.0.0.1       XXXXXXX-221227.this.that.foo.other

::1             XXXXXXX-221227.this.that.foo.other

I assume this was related to the above issue with tomcat and a numeric name... as my computer name (supplied by the corporation) had numbers in it.

In any case, as soon as I could ping XXXXXXX-221227.this.that.foo.other (obviously now the same as pinging localhost or 127.0.0.1) the spring boot app started (From the Spring Tools Suite UI) with no problem.

Oddly, the spring boot app started FINE from the command line with:

 mvn spring-boot:run 

-- I have no idea what the difference is/was.

like image 5
jb62 Avatar answered Nov 16 '22 18:11

jb62