tags:

views:

198

answers:

2

I am a bit puzzled by this strange behavior on CentOs 5.4 when starting Tomcat 6.0 as a service

I've added a script at /etc/init.d/tomcat that can start/stop/restart Apache Tomcat 6.0 with user 'tomcat', and registered it as service. The problem with the service is that I am getting a 'Neither the JAVA_HOME nor the JRE_HOME environment variable is defined'. But when type 'sudo -u tomcat echo $JAVA_HOME' I get '/usr/java/jdk1.5.0_22' which is correct since I am using that JDK. What can I do about this?

+1  A: 

Have you tried forcing the JAVA_HOME env variable into the start script itself? Whenever I face a problem liek this I find it a good troubleshooting technique to try and track down where it is losing this info by setting it in the scripts themselves.

Gray Area
Yes. When I insert export JAVA_HOME=/usr/java/jdk1.5.0_22 directly in the $CATALINA_HOME/bin/startup.sh then it works no problem.
peter
A: 

Have you checked the paths in /etc/profile.d/java.sh ?

Also try checking which java version it return with: which java

this should return the exact paths in java.sh if not you have a misconfiguration. in the later case uninstall all java and reinstall latest jdk.

Anyhow this posts comes in handy in your favorites for later reference.

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

JeremySpouken
I don't have a /etc/profile.d/java.sh. Don't think that the JDK installed from rpm creates oneOn all users 'java -version' returns:java version "1.5.0_22"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode, sharing)
peter
Also 'echo $JAVA_HOME' return/usr/java/jdk1.5.0_22
peter