我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 帖子/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 ]
答案1
将 /etc/tomcat/tomcat.conf 中的 JAVA_HOME 替换为 /usr/java/jre1.8.0_51