Java VisualVM not able to connect to Jboss - java

Java VisualVM not able to connect Jboss server, when jboss server running with option -b 0.0.0.0.
jboss run script - run.sh -c web -b 0.0.0.0
When i try to run jboss with this like - run.sh -c web -b {MyIp}
then Java VisualVM is able to connect jboss server.
Can any one help me how to connect while jboss running with first option ( -b 0.0.0.0)
I am using this configuration in run.conf file in jboss
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=8077 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

Add this to JAVA_OPTS
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=8077 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=0.0.0.0"
instead of 0.0.0.0 use your system IP.

Related

How to connect Spring Boot application remotely in Visual VM?

I am new to Visual VM, how to connect to Spring Boot application remotely in Visual VM?
Multiple instances are running as a java -jar app.jar with random ports. How to connect from Visual VM, I have root access to the remote system. Do I need to enable any security configuration?
In the local system, applications shows up automatically but when I entered remote system IP address it's prompting Add JMX connection and Add jstatd connection.
We need to specify the remote IP ADDRESS and expose the listening PORT while running the jar.
Syntax:
java
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=<PORT>
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=<IP_ADDRESS>
-Dcom.sun.management.jmxremote.rmi.port=<PORT>
-jar app-1.0.0-SNAPSHOT.jar
Example: Listening port is 6001 and available for remote ip address 192.168.0.23
java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=6001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.0.23 -Dcom.sun.management.jmxremote.rmi.port=6001 -jar app-1.0.0-SNAPSHOT.jar
For More details about set up Visual VM https://github.com/M-Thirumal/installation_guide/blob/master/visualVm/visualvm_remote_set_up.md
I encountered this dilemma with Spring Boot as well. But I was not using a jar. I passed the jmx arguments to maven to profile the application without having to build a jar first.
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.rmi.port=9010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost"
For more details, I documented my steps here.

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

Start WildFly with nohup standalone full

I want to start the WildFly 11 using the standalone-full.xml instead standalone.xml.
So I have to execute the command:
sh standalone.sh -c standalone-full.xml
inside folder wildfly-11.0.0.Final/bin/.
But if I want to start the WildFly in silence mode with nohup, it doesn't start with parameter -c standalone-full.xml.
I tried with:
nohup ./standalone.sh -b 0.0.0.0 -c standalone-full.xml >/dev/null 2>&1 &
But it does not work.
What is the correct command to start WildFly with standalone-full.xml in silence mode in Linux?
Server information: cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.4"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.4 (Maipo)"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.4:GA:server"
Thanks.
Use the below cammand.
nohup sh standalone.sh -c standalone-full.xml > /dev/null &

JConsole for remote JMX access against JBoss AS7 standalone mode

I am trying to access Jconsole for monitoring JBoss of a remote machine in the same intranet, but I am getting:
Connection failed! The connection to user#service:jmx:remoting-jmx://192.168.124.x:9999 did not succeed.
OS: Ubuntu,
Command: ./jconsole -J-Djava.class.path=/home/stpl/software/jdk1.7.0_51/lib/jconsole.jar:/home/stpl/software/jdk1.7.0_51/lib/jconsole.jar/tools.jar:/home/stpl/software/jboss-as-7.1.1:/home/stpl/software/jdk1.7.0_51/lib/tools.jar
In the machine which I want to access I have done following changes:
standalone.xml: All inet address from 127.0.0.1 to 0.0.0.0 and
remoting-connector use-management-endpoint="false".
In standalone.conf added following:
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.server.default.config=standalone.xml"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=9999"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver"
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=192.168.124.31"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:../modules/org/jboss/logmanager/main/jboss-logmanager-1.2.2.GA.jar -Xbootclasspath/p:../modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar -Xbootclasspath/p:../modules/org/apache/log4j/main/log4j-1.2.16.jar"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.logmanager"
I can access admin console from the remote machine and can telnet successfully for port 9999.
Kindly tell the clear steps for the same as I googled a lot but couldn't succeed to find solution .
Any help will be highly appreciated!
This worked for after following changes:
In standalone.xml, added remoting-connector use-management-endpoint="true"
like:-
<subsystem xmlns="urn:jboss:domain:jmx:1.1">
<show-model value="true"/>
<remoting-connector use-management-endpoint="true"/>
</subsystem>
Instead of running from JDK run this command from JBoss bin:
$JBOSS_HOME/bin/jconsole.sh
No configuration changes required in standalone.conf
In jconsole.sh set path for the JAVA_HOME and JBOSS_HOME and following jar classpath:
CLASSPATH=$JAVA_HOME/lib/jconsole.jar
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
CLASSPATH=$CLASSPATH:/home/stpl/software/jboss-as-7.1.1.Final/bin/client/jboss-client.jar

How to enable the JMX of cluster servers on Weblogic?(not the Weblogic AdminServer itself)

I am running Weblogic 12c on CentOS6. I have enabled the JMX on Weblogic AdminServer.
But I want to enable the JMX on the cluster servers such as ms1 listed below to monitor specific Java service. What shall I do? Thank you!
Servers:AdminServer(admin)
Clusters: ms1/ms2/ms3
[root#weblogic61 bin]# ps -ef |grep java
weblogic 3618 3571 0 Jun04 ? 03:14:41 /home/jdk/jdk1.7.0_45/bin/java -server -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m -Dweblogic.Name=ms1 -Djava.security.policy=/home/weblogic/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Dweblogic.security.SSL.trustedCAKeyStore=/home/weblogic/Oracle/Middleware/wlserver_12.1/server/lib/cacerts -Djava.endorsed.dirs=/home/jdk/jdk1.7.0_45/jre/lib/endorsed:/home/weblogic/Oracle/Middleware/wlserver_12.1/endorsed -da -Dplatform.home=/home/weblogic/Oracle/Middleware/wlserver_12.1 -Dwls.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.management.discover=false -Dweblogic.management.server=http://192.168.97.61:7001 -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/home/weblogic/Oracle/Middleware/patch_wls1211/profiles/default/sysext_manifest_classpath:/home/weblogic/Oracle/Middleware/patch_ocp371/profiles/default/sysext_manifest_classpath weblogic.Server
root 27588 27541 41 09:56 pts/0 00:00:25 /home/jdk/jdk1.7.0_45/bin/java -server -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m -Dweblogic.Name=AdminServer -Djava.security.policy=/home/weblogic/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Djava.endorsed.dirs=/home/jdk/jdk1.7.0_45/jre/lib/endorsed:/home/weblogic/Oracle/Middleware/wlserver_12.1/endorsed -Djava.rmi.server.hostname=192.168.97.61 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -da -Dplatform.home=/home/weblogic/Oracle/Middleware/wlserver_12.1 -Dwls.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/home/weblogic/Oracle/Middleware/patch_wls1211/profiles/default/sysext_manifest_classpath:/home/weblogic/Oracle/Middleware/patch_ocp371/profiles/default/sysext_manifest_classpath weblogic.Server
root 27638 27312 0 09:57 pts/1 00:00:00 grep java
zabbix 27853 1 0 Jun13 ? 00:14:16 java -server -classpath lib:lib/logback-classic-0.9.27.jar:lib/logback-core-0.9.27.jar:lib/org-json-2010-12-28.jar:lib/slf4j-api-1.6.1.jar:bin/zabbix-java-gateway-2.0.12.jar -Dzabbix.pidFile=/var/run/zabbix/zabbix_java.pid -Dzabbix.listenIP=0.0.0.0 -Dzabbix.listenPort=10052 -Dzabbix.startPollers=5 com.zabbix.gateway.JavaGateway
The first question is where are those settings coming from for your admin server. My guess is you need to edit startWebLogic.sh and find where the following are being set:
JAVA_OPTIONS="-Dcom.sun.management.jmxremote.port=12345"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTIONS="${JAVA_OPTIONS} -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
export JAVA_OPTIONS
Thos settings are probably being explicitly set for your admin server only based on an if statement or some such.
You can also set those -D values for your managed server by going to:
Admin Console -> Servers -> MS -> Server Start -> JVM Arguments
Last, in the Weblogic Domain->Configuration->General->Advanced
Enable both - Platform MBean Server Enabled and Platform MBean Server Used
Admin Console -> Servers -> Server-1 -> Server Start -> JVM Arguments
-DUseSunHttpHandler=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8501 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.20.209
Admin Console -> Servers -> Server-2 -> Server Start -> JVM Arguments
-DUseSunHttpHandler=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8502 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.20.209
along with below command line parameters ,
-Dcom.sun.management.jmxremote.port='you jmx port'
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder
Sometimes in the linux servers , imx connection doesn't get succeeded. that is because , in cloud linux host, in /etc/hosts so that the hostname resolves to the host address.
the best way to fix it is, ping the particular linux server from other machine in network and use that host IP address in the
-Djava.rmi.server.hostname=IP address that obtained when you ping that linux server.
But never rely on the ipaddress that you get from linux server using ifconfig.me. the ip that you get there is masked one which is present in the host file.

Categories