0

Tomcat 7 from repository and Debian Wheezy.

If I try to start Tomcat by service it does not work

service tomcat7 start
[FAIL] no JDK found - please set JAVA_HOME ... failed!

But the variable is there

/var/lib/tomcat7/conf# echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle

If I try from init.d it does work

/etc/init.d/tomcat7 start
[ ok ] Starting Tomcat servlet engine: tomcat7.

Looking in the /etc/inittab

# The default runlevel.
id:2:initdefault:

The default seems to be the 2

So, looking in the /etc/rc2.d

lrwxrwxrwx 1 root root  17 Nov 18 22:50 S01tomcat7 -> ../init.d/tomcat7

It seems it refers always to the same /etc/init.d/tomcat7 and I do not understand why it fails (complaining about java)..

elect
  • 203
  • 4
  • 17

2 Answers2

3

When you run an init script directly, your shell's environment is used. When you run the service command, it is not. You should set JAVA_HOME in /etc/default/tomcat7.

sciurus
  • 12,678
  • 2
  • 31
  • 49
0

You need to create an environment variable called JAVA_HOME with the value of the directory path of your Java installation.

If you are doing deployment use the jre path, if you need access to the development tools use the jdk path.

ErikE
  • 4,746
  • 1
  • 20
  • 27