Integration of JMX in Wildfly - java

I have been meaning to monitor my wildfly in zabbix through JMX. The versions are listed below
wildfly: 20.0.0.1 final
zabbix: 5.0.7
java(that is present in wildfly host): openjdk version "11.0.8" 2020-07-14
The issue i am facing while i run wildlfy is as follows.
-Xbootclasspath is no longer a supported option. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit
My standalone.conf file looks like as below:
if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.bytemani,org.joss.logmanager"
fi
# Uncomment the following line to prevent manipulation of JVM options
# by shell scripts.
#
#PRESERVE_JAVA_OPTS=true
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms2G -Xmx2G -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=1G -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath:/opt/wildfly/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.15.Final.jar"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
As per my research, i have found that my java version is not compatible and i dont know the work around process.

Related

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

Java api running in wildfly stopped responding

I have a java api service deployed in wildfly on Amazon linux, randomly the api calls are not reaching the api-service at all, but the wildfly is up and running, the memory/cpu usage seems normal at this point. I couldn't see any error on the application log.
When I restart wildfly, the application work normally.
Any pointers to debug this issue? Thank you
Wildfly Configuration
# General configuration for the init.d scripts,
# not necessarily for JBoss AS itself.
# default location: /etc/default/wildfly
## Location of JDK
JAVA_HOME="/usr/"
## Location of WildFly
JBOSS_HOME="/opt/wildfly"
## The username who should own the process.
JBOSS_USER=root
## The mode WildFly should start, standalone or domain
JBOSS_MODE=standalone
## Configuration for standalone mode
JBOSS_CONFIG=standalone.xml
## Configuration for domain mode
# JBOSS_DOMAIN_CONFIG=domain.xml
# JBOSS_HOST_CONFIG=host-master.xml
## The amount of time to wait for startup
STARTUP_WAIT=60
## The amount of time to wait for shutdown
SHUTDOWN_WAIT=60
## Location to keep the console log
JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log"
## Additionals args to include in startup
# JBOSS_OPTS="--admin-only -b 127.0.0.1"
JBOSS_OPTS="-Djboss.bind.address=xxx.xxx.xxx.xxx -DConfig=/opt/app-conf/app-conf.properties -DLogDirectory=/var/log/wildfly"
Here is the output of ps -ef | grep wildfly
/usr//bin/java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/wildfly/standalone/log/server.log -Dlogging.configuration=file:/opt/wildfly/standalone/configuration/logging.properties -jar /opt/wildfly/jboss-modules.jar -mp /opt/wildfly/modules org.jboss.as.standalone -Djboss.home.dir=/opt/wildfly -Djboss.server.base.dir=/opt/wildfly/standalone -c standalone.xml -Djboss.bind.address=xxx.xxx.xxx.xxx -DConfig=/opt/app-conf/app-conf.properties -DLogDirectory=/var/log/wildfly
Can you help to check if the memory and heap space are right? Or should I increase what could be the optimal value for it?

'Error: JAVA_HOME is not defined correctly.' on mvn command

when I run the command
mvn version
in ubuntu I get the following error.
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/java-7-openjdk-amd64/bin/java
My java version is
java version "1.8.0_91" Java(TM) SE Runtime Environment (build
1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
And I run
sudo nano /etc/environment
command and set java home and maven as
JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre"
M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
MAVEN_HOME=/usr/local/apache-maven/apache-maven-3.2.5
M2=/usr/local/apache-maven/apache-maven-3.2.5/bin
And my path variable is -
/usr/share/maven3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/jre:/home/hduser/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/hadoop/bin:/usr/lib/sqoop/bin:/home/hduser/bin:/usr/lib/jvm/java-8-oracle/jre/bin
And run command
sudo nano ~/.bashrc
and set these at the end
JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export JRE_HOME
export PATH export M2_HOME=/usr/share/maven3 export M2=$M2_HOME/bin
export PATH=$M2:$PATH
I have install java 8 and remove java 7 and then run the mvn command and I am getting this error. I am curious to know why it is showing java 7 rather then java 8 and Please also suggest me some solution.
Thanks in advance
EDIT
My bashrc is -
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u#\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user#host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u#\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*al$
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
#=======================================
# Added by TKS to conexport PATH=$JAVA_HOME/bin:$PATH
figure HDFS
#=======================================
#HADOOP VARIABLES START
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
export HADOOP_HOME=/usr/local/hadoop
#export SQOOP_HOME=/usr/local/sqoop
export PATH=$PATH:$HADOOP_HOME/bin
#export PATH=$PATH:$SQOOP_HOME/bin
export SQOOP_HOME=/usr/lib/sqoop
#HADOOP VARIABLES END
JAVA_HOME=/usr/lib/jvm/java-8-oracle
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
I think your JAVA_HOME is supposed to be JDK and not JRE since Maven compile the Java code and there's no Java compiler (javac) in the JRE.
The following should be enough :
JAVA_HOME=/usr/lib/jvm/java-8-oracle
M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
PATH=$PATH:$JAVA_HOME/bin
PATH=$PATH:$M2_HOME/bin
Remove other M2 or MAVEN_HOME variables that you have declared.

Tomcat 6.0.35 installation on Mac OS X Mavericks 10.9

I am trying to install apache-tomcat-6.0.35 on Mac OS x 10.9, but I have this error in catalina.out when I run startup.sh :
/Library/Tomcat/Home/bin/catalina.sh: line 375: /Library/Java/Home/bin/java: No such file or directory
And thus, the server isn't launched.
Here is what I get in terminal (bash) :
myMac:bin administrator$ ./startup.sh
Using CATALINA_BASE: /Library/Tomcat/Home
Using CATALINA_HOME: /Library/Tomcat/Home
Using CATALINA_TMPDIR: /Library/Tomcat/Home/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/Home/bin/bootstrap.jar
Any advice?
It seems the issue is related to your JAVA_HOME environment variable. Check to see if it is correctly set. To verify, run
javac -version or which java
on the command line to see which version of java is set and is the correct one that should be used.
I had the same issue, and I've made it work under OS X 10.9, with Java 6 (1.6.0_37-b06-434).
As it was complaining about a wrong path in Java in the catalina.out, I changed all the paths to my JRM in setclasspath.sh :
Old path :
/System/Library/Frameworks/JavaVM.framework/Versions/Current
New path :
/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home
There were 3 places affected :
if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
# Bugzilla 37284 (reviewed).
if $darwin; then
if [ -d "/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home" ]; then
export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home"
fi
[...]
# OSX hack to CLASSPATH
JIKESPATH=
if [ `uname -s` = "Darwin" ]; then
OSXHACK="/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home"
[...]
As you can see, the code already export JAVA_HOME, so no need to export it in .bash_profile here.

Java VisualVM not able to connect to Jboss

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.

Categories