Tomcat – Not able to stop tomcat7 by tomcat service

tomcattomcat7ubuntu-14.04

I am using Ubuntu 14.04 and Tomcat7.

For some reason, I needed to upgrade java-7 to java-8. So I installed openjdk-8 and set it default using update-alternatives --config java command. To my surprise, tomcat was still using java7.

To resolve the issue, I modified the /usr/share/tomcat7/bin/setenv.sh file and added following line.

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

Now tomcat7 is using java-8 but because of above modification in setenv.sh file, I am not able to stop tomcat server using service tomcat7 stop. It shows the [OK] message but tomcat process is still running.

Any suggestions ?

EDIT-1 : I have also noticed that service tomcat7 start is starting the tomcat server but printing below text on console.

* Starting Tomcat servlet engine tomcat7 [fail]

EDIT-2 : I had set JAVA_HOME(which points to Java8) in setenv.sh then service is not working but when I removed JAVA_HOME from setenv.sh and put it in catalina.sh then everything is working as expected.

Best Answer

when service tomcat7 status tells that tomcat do not run properly, search in journalctl xe what is going on. If you cannot repair it yourself, there should be any log published here, to help other people repair the same problem and to repair it quickly. Without any logs you can repair it in week, two. with logs and right, detailed answer it can be day or two.

You have sure you installed properly your java? Your java version?

Tomcat 7.0 is designed to run on Java SE 6 and later.

In addition, Tomcat 7.0 uses the Eclipse JDT Java compiler for compiling JSP pages. This means you no longer need to have the complete Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment (JRE) is sufficient. The Eclipse JDT Java compiler is bundled with the binary Tomcat distributions. Tomcat can also be configured to use the compiler from the JDK to compile JSPs, or any other Java compiler supported by Apache Ant.

In web a lot posts tells there was compiling bug tomcat7 with java8 in 2014 and 2015 year. Maybe it is the problem? What we can do without logs?