tomcat 서비스 시작 오류
centos 에서 /etc/init.d/tomcat 스크립트를 실행하니 아래와 같은 오류가 발생
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
원인은 catalina나 기동할 때 JAVA_HOME 이나 JRE_HOME 가 시스템 PATH에 인식되지 않아 발생하는 에러
해결 방법으로 tomcat 스크립트에 export JAVA_HOME 추가
vi /etc/init.d/tomcat
export JAVA_HOME=/usr/local/jdk1.8.26
아래는 tomcat 스크립트
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 2345 90 90
export JAVA_HOME=/usr/local/jdk1.8.26
CATALINA_HOME=export JAVA_HOME=/usr/local/tomcat8
function tomcat_start(){
/bin/sh $CATALINA_HOME/bin/startup.sh
}
function tomcat_stop(){
/bin/sh $CATALINA_HOME/bin/shutdown.sh
sleep 1
PS_LIST=`ps -ef | grep tomcat8 | grep -v grep | awk '{print $2}'`
for PID in $PS_LIST
do
echo "tomcat8 pid=$PID"
kill -9 $PID
sleep 0.5
done
}
case $1 in
start)
tomcat_start
;;
stop)
tomcat_stop
;;
restart)
tomcat_stop
tomcat_start
;;
esac
exit 0