I am using visualvm tool and trying to connect to my remote server ubuntu(14.04). In ubuntu my application is running on Docker. The Dockerfile looks like-
FROM anapsix/alpine-java:8_jdk
MAINTAINER user
ENV OFFLINE_DB_USERNAME abc123
ENV OFFLINE_DB_URL jdbc:mysql://x.x.x.x:xxxx/%s?useLegacyDatetimeCode=false&useTimezone=true&serverTimezone=UTC
ENV OFFLINE_DB_SERVER_URL jdbc:mysql://x.x.x.x:xxxx/offlineserver?useLegacyDatetimeCode=false&useTimezone=true&serverTimezone=UTC
ENV OFFLINE_DB_PASSWORD password123
CMD ["java", "-Dcom.sun.management.jmxremote","-Dcom.sun.management.jmxremote.port=9990", "-Dcom.sun.management.jmxremote.rmi.port=9991" "-Dcom.sun.management.jmxremote.local.only=false", "-Dcom.sun.management.jmxremote.authenticate=false","-Dcom.sun.management.jmxremote.ssl=false", "-Djava.rmi.server.hostname=x.x.x.x"
COPY sampleproject.jar /home/ubuntu/test/sampleproject.jar
CMD ["java","-jar","/home/ubuntu/test/sampleproject.jar"]
Expose 9990
I executed the below command to check whether port:9990 is listening or not. It showed following output-
$ netstat -lp | grep 9990
tcp6 0 0 [::]:9990 [::]:* LISTEN 1666/docker-proxy
But on trying to connect to a remote server with hostname:port(x.x.x.x:9990) i am getting the error as -Cannot connect to x.x.x.x:9990 using service:jmx:rmi:///jndi/rmi://x.x.x.x:9990/jmxrmi.