我在系统Tomcat7
上进行了安装CentOS (6.7)
。Tomcat不会运行,抛出异常catalina.out
/usr/sbin/tomcat: line 29: -classpath: command not found
和相关的tomcat-initd.log
/usr/sbin/tomcat: error: Failed to set JAVACMD
根据这个 SF post,我应该可以这样设置/usr/share/java-utils/java-functions
:
# Add all sorts of jvm layouts here
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
JAVACMD="$JAVA_HOME/jre/sh/java"
elif [ -x "$JAVA_HOME/bin/java" ]; then
JAVACMD="$JAVA_HOME/bin/java"
else
JAVACMD=`which java 2>/dev/null`
fi
if [ ! -x "$JAVACMD" ]; then
echo "$0: error: Failed to set JAVACMD"
return 1
fi
但我仍然得到例外。少了什么东西?我不明白什么,我该如何解决异常?
JAVA_HOME 设置:
echo $JAVA_HOME
/usr/java/jdk1.7.0_79
检查tomcat状态:
sudo service tomcat status
PID file exists, but process is not running [WARNING]
tomcat lockfile exists but process is not running [FAILED]
即使在删除 Tomcat pid 文件、冲洗并重复之后也是如此。
请求响应:
whereis java
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java
ls -lad /usr/bin/java
lrwxrwxrwx. 1 root root 21 Jul 21 2015 /usr/bin/java -> /usr/java/jre1.8.0_51
ls -lad /etc/alternatives/java
lrwxrwxrwx. 1 root root 20 Jul 21 2015 /etc/alternatives/java -> /usr/java/glassfish4
在注释掉JAVA_HOME
之后tomcat.conf
/etc/rc.d/init.d/tomcat start
Starting tomcat: [ OK ]
sudo service tomcat status
tomcat (pid 13517) is running... [ OK ]
将 /etc/tomcat/tomcat.conf 中的 JAVA_HOME 替换为 /usr/java/jre1.8.0_51