Glassfish 4.1 MalformedURLException when using Kubernetes and Docker.

Due to constraints in the way the JMX is setup, I was finding my glass fish instance could not be stood up when using kubernetes. The main reason was because the way the HOSTNAME was being generated has a character in it that causes the MalformedURLException.

To fix this, I added the following line to my startup script run by my dockerfile:

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

This will cause the hostname to resolve to the localhost and should fix the malformed exception.