I am new to VisualVM and trying to monitor some application which is deployed on Tomcat 9 CentOS server. I have installed VisualVM on my Windows laptop and trying to remote connect to the JVM on the CentOS server, but nothing is displayed (message on VisualVM: Not supported for this JVM).
Please find below Java version installed on CentOS server:
[root#localhost bin]# java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
Based on the online resource I saw, I need to enable JMX on Tomcat, so I have added the following properties in my setenv.sh (in tomcat/bin folder) file:
export CATALINA_OPTS="\
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=8999 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false"
I have downloaded the latest VisualVM and created a remote host via File->Add Remote Host. Then Add JMX Connection info as follows:
connection:dymmyip:8999
username :user
Password :dummyPassword
uncheck :do not require ssl
When I try to connect, the following screen is displayed:
Can anyone tell me please what I am missing here?
You can add the missing =true in your setenv.sh
export CATALINA_OPTS="\
-Dcom.sun.management.jmxremote=true \
-Dcom.sun.management.jmxremote.port=8999 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false"
You have to chmod you setenv.sh too:
$ cd <your-tomcat-dir>/bin
$ chmod a+x setenv.sh
Be sure it is not a firewall issue. Test the connection with telnet dummyip 8999
Be sure using the same JVM on both VisualVM and Tomcat. (Be careful with architecture too: 32 or 64bits)
You can get the last release of VisualVM here.
To install it:
$ [ -f "/usr/bin/visualvm" ] && sudo mv /usr/bin/visualvm{,.old}
$ wget https://github.com/oracle/visualvm/releases/download/2.1.4/visualvm_214.zip
$ unzip visualvm_214.zip
$ sudo mv visualvm_214 /opt/
$ sudo ln -s /opt/visualvm_214/bin/visualvm /usr/bin/
$ visualvm --jdkhome /usr/lib/jvm/java-17-openjdk-amd64
Use the path you want in --jdkhome.
Related
I'm trying to run a simple Tomcat8 server on my Ubuntu 16.04 Docker image. But I can't see the Tomcat default page.
1) I ran this command to run the container docker run -it --entrypoint bash e36658dffbd8
2) I opened up localhost:8080/ after installing tomcat8 in my container but it doesn't work.
Here is my Dockerfile
FROM ubuntu:16.04
# OS: Ubuntu 16.04
# Tomcat Setup
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
RUN apt-get update
RUN apt-get install -y tomcat8 openjdk-8-jre-headless exuberant-ctags git telnet subversion mercurial wget inotify-tools unzip sysstat vim procps virtualenv python3-pip
EXPOSE 7443
EXPOSE 8080
You need to tell docker to map the exposed port to a local port:
docker run -it -p 8080:8080 --entrypoint bash e36658dffbd8
Also, I don't see anything in your dockerfile that will actually install Tomcat, so that would be a different problem.
I am trying to integrate SonarQube into my CI process. I tried to install SonarScanner in Docker, but it appears it cannot find java tho it can be run
Dockerfile
# Docker, AWS CLI, Terraform, NodeJS
FROM docker:18-dind
RUN echo "1"
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
RUN apk update
RUN apk add awscli nodejs nodejs-npm wget unzip jq openjdk11
RUN wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
RUN unzip terraform_0.11.13_linux_amd64.zip
RUN mv terraform /usr/local/bin
RUN npm i -g sequelize sequelize-cli mysql2
RUN wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873.zip
RUN unzip sonar-scanner-cli-4.2.0.1873.zip
RUN ls sonar-scanner-4.2.0.1873
ENV PATH="/sonar-scanner-4.2.0.1873/bin:${PATH}"
RUN which java
ENV JAVA_HOME=/usr/bin
RUN echo $PATH
RUN java --version
RUN ls /sonar-scanner-4.2.0.1873/bin
RUN sonar-scanner --help
The logs
Step 15/20 : RUN which java
---> Running in 96b487f5b44f
/usr/bin/java
Removing intermediate container 96b487f5b44f
---> 5026de427a57
Step 16/20 : ENV JAVA_HOME=/usr/bin
---> Running in 4d7eee221e41
Removing intermediate container 4d7eee221e41
---> 76b9a8b9d803
Step 17/20 : RUN echo $PATH
---> Running in 4278142f7153
/sonar-scanner-4.2.0.1873/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Removing intermediate container 4278142f7153
---> c3d528bdaa7e
Step 18/20 : RUN java --version
---> Running in 7df7e2d8a441
openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-alpine-r0)
OpenJDK 64-Bit Server VM (build 11.0.5+10-alpine-r0, mixed mode)
Removing intermediate container 7df7e2d8a441
---> 0f7162dae25d
Step 19/20 : RUN ls /sonar-scanner-4.2.0.1873/bin
---> Running in b7efb86cd86e
sonar-scanner
sonar-scanner-debug
sonar-scanner-debug.bat
sonar-scanner.bat
Removing intermediate container b7efb86cd86e
---> ff640a70876f
Step 20/20 : RUN sonar-scanner --help
---> Running in 9164ac2e8369
Could not find 'java' executable in JAVA_HOME or PATH.
The command '/bin/sh -c sonar-scanner --help' returned a non-zero code: 1
Notice which java gives /usr/bin/java. So I set JAVA_HOME=/usr/bin. java can run. But sonar-scanner cannot appear to find java ... why is that?
Add JAVA_HOME ENV according to version, as mentioned #cricket_007 the path in alpine for JDK is /usr/lib/jvm/{VERSION}
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"
RUN echo $PATH
run docker
docker run --privileged -it --rm sonar-s sonar-scanner --version
output
INFO: Scanner configuration file: /sonar-scanner-4.2.0.1873/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 11.0.5 Alpine (64-bit)
INFO: Linux 4.14.70-67.55.amzn1.x86_64 amd64
I try to install java8 on my Linux server centOS. In /etc/profile
export JAVA_HOME=/root/jdk1.8.0_71/
export PATH=$JAVA_HOME/bin/:$PATH
[root#localhost ~]# echo $JAVA_HOME
/root/jdk1.8.0_71/
[root#localhost ~]# which java
/root/jdk1.8.0_71/bin/java
[root#localhost ~]#
And then I install Cassandra, but it cannot find the java8. And I execute some commands and get
[root#localhost ~]# su cassandra -c "echo $JAVA_HOME"
/root/jdk1.8.0_71/
[root#localhost ~]# su cassandra -c "whereis java"
java: /usr/bin/java /etc/java /usr/lib/java /usr/local/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
[root#localhost ~]# su cassandra -c "which java"
which: no java in (/root/jdk1.8.0_71//bin/:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
I want to know since the PATH is right, why I failed to get java using which java?
And then I create soft link and change the mode of /root/jdk1.8.0_71 to 777
cd /usr/bin
java -> /root/jdk1.8.0_71/bin/java
But it is still not work. Did I miss somethings or make anything wrong?
If the user Cassandra does not have permission on the /root folder then it wont be able to find it. I don't know why would you copy the JDK in the /root folder. My suggestion is to copy the jdk1.8.0_71 in the /opt folder and set the correct permission (owner or group), something like:
cp -r /root/jdk1.8.0_71 /opt
chown -R cassandra.cassandra /opt
Additional, setting paths in the PATH variable should not include the trailing to avoid "/root/jdk1.8.0_71//bin/"
I follow the steps largely from https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-14-04
Let me iterate the steps I took:
i logged in as ubuntu user
sudo apt-get install tomcat8
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
cd ~
wget http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz
sudo mkdir /opt/tomcat
sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat
sudo chgrp -R tomcat conf
sudo chmod g+rwx conf
sudo chmod g+r conf/*
sudo chown -R tomcat work/ temp/ logs/
sudo update-alternatives --config java and selected /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
sudo nano /etc/init/tomcat.conf
and typed
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid tomcat
setgid tomcat
env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
env CATALINA_HOME=/opt/tomcat
# Modify these options as needed
env JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
env CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
exec $CATALINA_HOME/bin/catalina.sh run
# cleanup temp directory after stop
post-stop script
rm -rf $CATALINA_HOME/temp/*
end script
sudo initctl reload-configuration
sudo initctl start tomcat
which leads to
tomcat start/running, process 14674
But when I go to http://[ip-address]:8080 nothing happens.
Please advise.
UPDATE
One comment below asked me to look at server.xml inside tomcat root folder bin.
I have reproduced the following files:
Which proves that there is no such file inside /opt/tomcat/bin
I have also appended some statements from server.xml below which is inside /opt/tomcat/conf
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Server port="8005" shutdown="SHUTDOWN">
Just use
sudo chown -R tomcat:tomcat /opt/tomcat
This worked for me after useing the very same manual.
If you want clean Ubuntu style package instead, the following should do it...
mkdir $HOME/tomcat8 && cd $HOME/tomcat8
wget http://mirrors.kernel.org/ubuntu/pool/main/e/ecj/libecj-java_3.10.1-2_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/libservlet3.1-java_8.0.28-1_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/libtomcat8-java_8.0.28-1_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/tomcat8-common_8.0.28-1_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/tomcat8_8.0.28-1_all.deb
dpkg -i *.deb
However, you're not on PPA. This isn't managed by apt anymore. You'll need to upgrade it manually whenever an update is made to the packages.
I had the same problem. I installed Oracle JDK 7, HOWEVER, I still used JAVA_HOME in tomcat.conf that was pointing to Open JDK:
env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
Make sure you are using the right version of Java. For me, I set it in tomcat.conf as follows:
env JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
Then, do ps -ef | grep tomcat after re-starting tomcat and you should get something like this if tomcat is running:
tomcat 1580 1 9 14:47 ? 00:00:03 /usr/lib/jvm/java-7-oracle/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Dja
ger=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=2
ParallelGC -Djava.endorsed.dirs=/opt/tomcat/endorsed -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcat
t -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
ubuntu 1607 1423 0 14:48 pts/0 00:00:00 grep --color=auto tomcat
Also, my environment file has the following:
export JAVA_HOME="/usr/lib/jvm/java-7-oracle/jre"
export CATALINA_HOME="/opt/tomcat"
Hope this helps!
Instead of: http://serverip:8080
I used http://localhost:8080
That replacement worked for me.
I have simple solution for installing any version of apache tomcat on Ubuntu.
Simplest Way of Installing any version Apache Tomcat Installation Steps on Ubuntu.
Download any version of tomcat you wish to install from apache tomcat official website.(.tar/.zip)
Extract the tomcat tar/zip file to any folder/directory in your linux pc.
Copy the extracted folder to /opt directory
directory looks like /opt/tomcat using cp command.
for e.g. sudo cp /Documents/apache-tomcat-8-0-24 /opt
This will copy my apache-tomcat-8-0-24 folder in Documents folder to /opt directory.
come back to /opt directory /opt
cd /opt
you are at /opt run following command
sudo chown -R username:username
for e.g. sudo chown -R akashgudadhe apache-tomcat-8-0-24
you are at /opt
ls -la
verify apache present or not
move to apache-tomcat-8-0-24 folder and bin directory inside it
/opt/apacheTomcatName/bin
you are now at /opt/apacheTomcatName/bin
run startup.sh file using following command you will see the message tomcat started.
for e.g. /opt/apacheTomcatName/bin/./startup.sh
This is optional step
tail -f logs/catalina.out
Open any web browser and type
localhost:8080 or type 127.0.0.1:8080
your tomcat installed successfully if not then mail me # gooddaysky1#gmail.com
It will become great pleasure for me if you send me your feedback about my answer # gooddaysky1#gmail.com ...!!!
Open Server.xml and find <Connector port="9090" protocol="HTTP/1.1" so that is your port number .
You have to write:
cd /opt/tomcat/bin
and after:
sudo bash startup.sh
and all well!!!
http://serverip:8080
NOTE: If you put the port 9090, then PLACED IN YOUR BROWSER http://serverip:9090
Im trying to get JAVA enabled on Intel Edison which uses Yocto (Linux), the problem is that after extracting the zip, im able to check the version, and when putting it into the path, im not able to access java at all due permissions.
Specifically im trying to follow this tutorial but i get "stuck" at the
. .profile
since next step
java -version
throws same issue as pasted below, permissions denied or as earlier, java was not found.
Heres a quick overview of output:
root#dedsec1:~/java/jdk1.7.0_67/bin# ./java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode)
root#dedsec1:~/java/jdk1.7.0_67/bin# cd
root#dedsec1:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/root/bin:/home/root/java/jdk1.7.0_67/bin:/home/root/java/jdk1.7.0_67/bin
root#dedsec1:~# ./java -version
-sh: ./java: Permission denied
root#dedsec1:~#
What the hell am i missing ? I have set chmod -x on java but it doesnt seem to affect it.
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0
root's home folder is not under "/home". Change this
/home/root/java/jdk1.7.0_67/bin:/home/root/java/jdk1.7.0_67/bin
to
/root/java/jdk1.7.0_67/bin
Also,
/home/root/bin
should probably be
/root/bin
For similar reasons. When writing a script you can use $HOME which will expand to wherever the user's home directory happens to be. So,
PATH="$HOME/bin:$HOME/java/jdk1.7.0_67/bin"
Edit
I would not recommend that you link to java in $HOME/bin. Let's set a JAVA_HOME and move that to the front of the PATH like
export JAVA_HOME=$HOME/java/jdk1.7.0_67
export PATH="$JAVA_HOME/bin:$HOME/bin:$PATH"
You need to be logged in as Root
. .profile
If that doesn't work you can source your file.
source .profile
note that source is a synonym of '.' (period).