Tomcat startup.sh JAVA_HOME search problem

I am a little puzzled by this strange behavior in CentOs 5.4 when running Tomcat 6.0 as a service

I added a script to /etc/init.d/tomcat that can start / stop / restart Apache Tomcat 6.0 using the tomcat user and register it as a service. The problem with the service is that I get "Neither JAVA_HOME nor JRE_HOME environment variable set." But when "sudo -u tomcat echo $ JAVA_HOME" I get "/usr/java/jdk1.5.0_22", that’s right, since I use this JDK. What can I do about this?

+5
source share
4 answers

Have you tried to force the env variable JAVA_HOME at the very beginning of the script? Whenever I encounter such a problem, I find it a good troubleshooting technique to try to track where it loses this information by installing it in the scripts themselves.

+2
source

I had the same problem and it was solved by placing the variable definition JAVA_HOMEin the file /etc/environment.

First, I created an environment variable JAVA_HOMEthat calls:

$ export JAVA_HOME=<path_to_my_java_home>

Then I realized that the Tomcat startup.shscript could not access the value of the variable JAVA_HOMEwhen it was called with the help sudothat is needed to start the Tomcat server.

At first, I tried to export the variable JAVA_HOMEusing sudo, but this did not work:

$ sudo export JAVA_HOME=<path_to_my_java_home>
sudo: export: command not found

JAVA_HOME /etc/environment. /etc/enviroment:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME=/usr/lib/jvm/java-7-oracle

Tomcat startup.sh script sudo http://localhost:8080, Tomcat, , .

+10

/etc/profile.d/java.sh?

, java : java

java.sh, . java jdk.

, .

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=5717&forum=28

0

bin/catalina.sh JAVA_HOME crontab

# For CRONTAB
export JAVA_HOME=/usr/java/latest
# END
0
source

All Articles