install tomcat 8.0.24 on ubuntu 14.04 - java

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

Related

Unable to remote connect VisualVM to CentOS

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.

How to install openjdk on seleniarm/standalone-chromium (debian)

I need to run both selenium and OpenJdk. I have a current Dockerfile that does work on M1 Mac which as the ARM architecture, (below). But the JDK version that it uses is 11.0.14+9-post-Debian-1deb11u1:
FROM seleniarm/standalone-chromium:101.0.4951.41-chromedriver-101.0.4951.41-20220429
ENV CHROMEDRIVER_PORT 4444
ENV CHROMEDRIVER_WHITELISTED_IPS "127.0.0.1"
ENV CHROMEDRIVER_URL_BASE ''
EXPOSE 4444
EXPOSE 8080
EXPOSE 5005
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar", "-Xmx600m","/app.jar"]
My prior Dockerfile is:
FROM maven:3.6.3-openjdk-15
# Google Chrome
ARG CHROME_VERSION=96.0.4664.45-1
ADD google-chrome.repo /etc/yum.repos.d/google-chrome.repo
RUN microdnf install -y google-chrome-stable-$CHROME_VERSION \
&& sed -i 's/"$HERE\/chrome"/"$HERE\/chrome" --no-sandbox/g' /opt/google/chrome/google-chrome
## ChromeDriver
ARG CHROME_DRIVER_VERSION=96.0.4664.45
RUN microdnf install -y unzip \
&& curl -s -o /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
&& unzip /tmp/chromedriver.zip -d /opt \
&& rm /tmp/chromedriver.zip \
&& mv /opt/chromedriver /opt/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /opt/chromedriver-$CHROME_DRIVER_VERSION \
&& ln -s /opt/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
ENV CHROMEDRIVER_PORT 4444
ENV CHROMEDRIVER_WHITELISTED_IPS "127.0.0.1"
ENV CHROMEDRIVER_URL_BASE ''
EXPOSE 4444
EXPOSE 8080
EXPOSE 5005
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar", "-Xmx600m","/app.jar"]
Note that FROM maven:3.6.3-openjdk-15 naturally says the jdk version and allows that. But I do not know how to achieve this with standalone-chromium. Does anyone know how to install openjdk (in Docker) with a given version in this case?
I'm not exactly sure what your goal is, whether you're intending to run a Selenium server alongside some other JAR file or if you're just looking to use some of the components from seleniarm/standalone-chromium. I assume the latter, since ENTRYPOINT appears to override seleniarm/standalone-chromium's call to /opt/entry-point.sh.
Regardless of the specific use-case, here's what you can do to install a different OpenJDK:
FROM seleniarm/standalone-chromium:latest
USER root
COPY openjdk-15.0.2_linux-aarch64_bin.tar.gz /opt
RUN mkdir -p /opt/jdk \
# && curl -L https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-aarch64_bin.tar.gz -o /opt/openjdk-15.0.2_linux-aarch64_bin.tar.gz \
&& cd /opt/jdk && tar xvfz /opt/openjdk-15.0.2_linux-aarch64_bin.tar.gz \
&& export PATH=/opt/jdk/jdk-15.0.2/bin:$PATH \
#&& echo "export PATH=/opt/jdk/jdk-15.0.2/bin:$PATH" >> /home/seluser/.bashrc \
#&& echo "export PATH=/opt/jdk/jdk-15.0.2/bin:$PATH" >> /root/.bashrc \
&& rm /usr/bin/java \
&& ln -s /opt/jdk/jdk-15.0.2/bin/java /usr/bin/java \
&& java -version
ENV CHROMEDRIVER_PORT 4444
ENV CHROMEDRIVER_WHITELISTED_IPS "127.0.0.1"
ENV CHROMEDRIVER_URL_BASE ''
EXPOSE 4444
EXPOSE 8080
EXPOSE 5005
USER 1200
#ARG JAR_FILE=target/*.jar
#COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-version"]
Then build the container image:
$ docker build -t local/jdk15:latest .
And then run it and get the java version output:
$ docker run --rm -it local/jdk15:latest
openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode)
I left some of the commented script to show what didn't work. Setting the PATH in the .bashrc worked when bashing into the container, but it didn't work with ENTRYPOINT. Instead, creating a symlink to the /usr/bin/java location resolved the issues. Note that this replaces the default Java installation launcher, and this should not be a problem within a container image.
I also copied a downloaded JDK tarball while debugging as this is faster than downloading the JDK each time we rebuild. In production, just comment out the COPY command and uncomment the curl line, which downloads OpenJDK 15 and places it in the /opt folder.
You can also uncomment the commands that copy your JAR file to the container image. I didn't have a JAR file to test with, but this should help get you started. Hope this helps.

Can't reach Tomcat default page in localhost:8080 for Ubuntu 16.04 Docker container

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.

OpenTSDB no JDK found

I'm having troubles starting OpenTSDB because no JDK is found allthough I've installed it and set JAVA_HOME. Here's what I've done:
1. Install JDK
sudo apt-get install openjdk-8-jdk
2. Set JAVA_HOME
I tried setting JAVA_HOME in 2 different ways:
Add JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" to /etc/environment
Add export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" to .bashrc
3. Download OpenTSDB
wget https://github.com/OpenTSDB/opentsdb/releases/download/v2.3.0/opentsdb-2.3.0_all.deb
4. Install OpenTSDB
dpkg -i opentsdb-2.3.0_all.deb
5. Start OpenTSDB
service opentsdb start
Each time I get the error "* no JDK found - please set JAVA_HOME". I've tried numerous times, what am I doing wrong?
This issue is also present in opentsdb 2.3.1. To fix this issue you should explicitly write your JAVA_HOME to the opentsdb init script (at /etc/init.d/opentsdb)
open the file /etc/init.d/opentsdb and add the path to your java installation
here is the fix:
JDK_DIRS=" Path_to_your_JDK_here \
/usr/lib/jvm/java-8-oracle /usr/lib/jvm/java-8-openjdk \
/usr/lib/jvm/java-8-openjdk-amd64/ /usr/lib/jvm/java-8-openjdk-i386/ \
\
/usr/lib/jvm/java-7-oracle /usr/lib/jvm/java-7-openjdk \
/usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-i386/ \
\
/usr/lib/jvm/default-java"
Do you try with these command after install jdk?
update-alternatives --display java
update-alternatives --config java
with this command select default JDK for the system.
Regards!

which: no java for my user on linux

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/"

Categories

Resources