Reputation: 83
I manually installed tomcat7.
It runs on terminal (tomcat started).
But when I try to run it on browser(localhost:8080), page html appears.
I can't find where is the problem
java version "1.7.0_79" OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2) OpenJDK Server VM (build 24.79-b02, mixed mode)
Using CATALINA_BASE: /opt/tomcat/
Using CATALINA_HOME: /opt/tomcat/
Using CATALINA_TMPDIR: /opt/tomcat//temp
Using JRE_HOME: /usr/lib/jvm/java-1.7.0-openjdk-i386
Using CLASSPATH:
/opt/tomcat//bin/bootstrap.jar:/opt/tomcat//bin/tomcat-juli.jar Tomcat started.
Thank you
Upvotes: 3
Views: 23187
Reputation: 1
For this question, I've seen some answers online that suggest it's because it's not executed with the root user's privileges. However, you will find that this doesn't work. It still shows r the following error:
Using CATALINA_BASE: /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_HOME: /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_TMPDIR: /home/nzwl2020/apache-tomcat-8.5.87/temp
Using JRE_HOME: /usr/loacl/java
Using CLASSPATH: /home/nzwl2020/apache-tomcat-8.5.87/bin/bootstrap.jar:/home/nzwl2020/apache-tomcat-8.5.87/bin/tomcat-juli.jar
Using CATALINA_OPTS:
./catalina.sh: 1: eval: /usr/loacl/java/bin/java: not found
If at this point you print the JAVA_HOME variable and the PATH variable, you will see that this is not the same as what you set when you installed the JDK and Tomcat earlier.
Also, we find that the java
command cannot be found.
java -version
找不到命令 “java”,但可以通过以下软件包安装它:
apt install openjdk-11-jre-headless # version 11.0.18+10-0ubuntu1~22.04, or
apt install default-jre # version 2:1.11-72build2
apt install openjdk-17-jre-headless # version 17.0.6+10-0ubuntu1~22.04
apt install openjdk-18-jre-headless # version 18.0.2+9-2~22.04
apt install openjdk-19-jre-headless # version 19.0.2+7-0ubuntu3~22.04
apt install openjdk-8-jre-headless # version 8u362-ga-0ubuntu1~22.04
That's because you used the su root
command instead of the su - root
command.
Compare the
su
andsu -
commands:su
switches the user's access, but does not get the environment variable, so PATH is not brought in;su -
is the full switching user, changing the working directory and getting environment variables, so you can find JAVA_HOME.When we use the normal
su
command to switch from one user to another, the current directory remains the same as the previous user.When we use the
su -
command to switch from one user to another, the current directory is changed to the target user's home directory.The
su
command does not create a new user environment, but rather thesu -
command creates a completely new user environment.
Switch to superuser with su - root
command, enter your user password (if you have one), go to the apache-tomcat-8.5.87/bin
directory, and execute the startup.sh
jscript file to start Tomcat. The following result will be displayed.
Using CATALINA_BASE: /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_HOME: /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_TMPDIR: /home/nzwl2020/apache-tomcat-8.5.87/temp
Using JRE_HOME: /usr/local/java
Using CLASSPATH: /home/nzwl2020/apache-tomcat-8.5.87/bin/bootstrap.jar:/home/nzwl2020/apache-tomcat-8.5.87/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
Check if the Tomcat process is running.
ps -ef | grep java
root 9524 1084 11 21:49 pts/2 00:00:03 /usr/local/java/bin/java -Djava.util.logging.config.file=/home/nzwl2020/apache-tomcat-8.5.87/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /home/nzwl2020/apache-tomcat-8.5.87/bin/bootstrap.jar:/home/nzwl2020/apache-tomcat-8.5.87/bin/tomcat-juli.jar -Dcatalina.base=/home/nzwl2020/apache-tomcat-8.5.87 -Dcatalina.home=/home/nzwl2020/apache-tomcat-8.5.87 -Djava.io.tmpdir=/home/nzwl2020/apache-tomcat-8.5.87/temp org.apache.catalina.startup.Bootstrap start root 9558 9442 0 21:49 pts/2 00:00:00 grep --color=auto java
netstat -anp | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 9524/java
Turn off the firewall.
ufw disable
Visit http://localhost:8080
in your browser (of course, your Tomcat's port may not be 8080).
Upvotes: 0
Reputation: 2692
Ok, now this may sound silly, but this problem occurred with me also. After a lot of brainwork, I came to this solution.
just add sudo
before ./startup.sh
Start tomcat server by the following command from the Tomcat bin
directory as:
$ sudo ./startup.sh
Hope this helps.
Upvotes: 3
Reputation: 17
Apache tomcat8.0.27 and lower does not work in jdk 9 change it to lower version. As of oct 2018. Results may change for updated version of tomcat.
Upvotes: 0
Reputation: 1
Check your download version of tomcat. if you open your extracted tomcat file folder,you must see log folder. else it's may be you install apache-tomcat-src.tar.gz. if your file path shows src, its not give you a log file. so delete tomcat folder and download apache-tomcat-8.tar.gz correct file. now install it.
Upvotes: 0
Reputation: 2324
If any error occur during tomcat startup time then that tomcat error is not shown on ubuntu terminal. So you need to check log file from following location.
{tomcat path}/logs/catalina.{date}.log
{tomcat path}
= tomcat install path.
{date}
= log of date.
Upvotes: 5
Reputation: 33
Check for these details :
1) Tomcat is running on which port
a) Check through netstat command if you know tomcat's PID : For example, I can see the PID of my tomcat is 1483. So using,
$ sudo netstat -lnp | grep 1483
I can see on which port it is running / using.
b) Inside tomcat : Check for this line in server.xml under conf directory inside tomcat :
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
2) Check whether you have enabled Proxy settings in browser.
3) Check whether you can access it via localhost or ip address or machine name. e.g. http://localhost:8080 , http://pc-name:8080, http://192.168.1.1:8080
4) Lastly, check for firewall / iptables and if possible, disable it temporarily and then try again or add in exceptions in firewall.
Upvotes: 0
Reputation: 3
Check if the JAVA Environment is set properly; It needs Java to be running on the box.
Upvotes: 0