简体   繁体   中英

Connection failed while connecting JConsole on Windows with remote Java Springboot app on Linux

I am starting the Java SpringBoot app on my RHEL server having java 1.8 installed with the following command:-

java -jar App.jar --spring.profiles.active=dev -Xms96m -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:loggc.log 
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=5901
-Dcom.sun.management.jmxremote.rmi.port=5901
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.local.only=false 
-Djava.rmi.server.hostname=localhost

When the jar has started successfully, a PID has been assigned and I wanted to monitor that PID for Heap Utilisation . So I am trying to achieve this by using JConsole on windows environment and binding the JMX port on Linux with a port on windows using Port Forwarding using putty.

But I am not able to connect successfully as there is a JRMP Connection failure.

Can someday give me an insight on what I might be doing wrong or if there is any better way to analyze the heap utilization in Linux environment.

I tried to access it via: jconsole 5901 but it says Non-JRMP server at the remote endpoint.

The order of the arguments is wrong. The arguments are available in as args in your main method, but Java runtime doesn't care about them.

java -h
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

With correct ordering, Java runtime will pickup the arguments and not your application.

java -Xms96m -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:loggc.log 
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=5901
-Dcom.sun.management.jmxremote.rmi.port=5901
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.local.only=false 
-Djava.rmi.server.hostname=localhost
-jar App.jar --spring.profiles.active=dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM