在配置测试环境时,将生产服务器的Tomcat目录打包过来后解压后,启动Tomcat后,发现如下问题:
[tomcat@gsp bin]$ ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_12
/usr/local/tomcat/bin/catalina.sh: line 315: /usr/java/jdk1.6.0_12/bin/java: No such file or directory
[tomcat@gsp bin]$ ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_12
[tomcat@gsp bin]$ cd /usr/java/jdk1.6.0_12
-bash: cd: /usr/java/jdk1.6.0_12: No such file or directory
因为在测试环境,安装的是jdk-6u31-linux-x64-rpm.bin,其实并没有所谓的/usr/java/jdk1.6.0_12目录,而是/usr/java/jdk1.6.0_31
[tomcat@CEG-eSCM jdk1.6.0_31]$ pwd
/usr/java/jdk1.6.0_31
于是修改了.bash_profile
[tomcat@gsp ~]$ more .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
JAVA_HOME=/usr/java/jdk1.6.0_31/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
PATH=$PATH:$HOME/bin
export PATH
但是当时忘了使用source .bash_profile 使配置信息生效,结果依然报这个错误,搜索了一下可以通过修改setclasspath.sh文件,在里面添加下面变量解决问题。如下所示
export JAVA_HOME=......
export JRE_HOME=.......
其实只要使.bash_profile配置文件生效了后,就可以将setclasspath.sh下的JAVA_HOME去掉了。在这个配置文件指定JAVA_HOME或JRE_HOME主要用于当服务器有多个版本的JDK时,指定tomcat使用某个特殊版本.
参考资料:
http://blog.csdn.net/eifjgoergfgrgr/article/details/7556882