我在帮助台票务系统 (SysAid) 服务器上运行了 tomcat7。重启后,tomcat7 服务没有启动。
当我在 catalina.out 文件中 grep tomcat7 时,我得到以下内容:
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false] INFO: Deploying web application archive /var/lib/tomcat7/webapps/sysaid.war WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false] WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false] INFO: Deploying web application archive /var/lib/tomcat7/webapps/sysaid.war Initializing log4j with: /var/lib/tomcat7/webapps/sysaid/./WEB-INF/log4j.properties Initializing log4j with: /var/lib/tomcat7/webapps/sysaid/./WEB-INF/log4j.properties INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
帮助台程序日志文件未提及 tomcat7 错误。
当我运行该程序的启动脚本时,我得到以下信息:
Using CATALINA_BASE: /usr/share/tomcat7 Using CATALINA_HOME: /usr/share/tomcat7 Using CATALINA_TMPDIR: /usr/share/tomcat7/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar touch: cannot touch ‘/usr/share/tomcat7/logs/catalina.out’: No such file or directory ./catalina.sh: 385: ./catalina.sh: cannot create /usr/share/tomcat7/logs/catalina.out: Directory nonexistent
我还检查以确保它已设置为在启动时通过 rc.d 运行,命令如下:sudo update-rc.d tomcat7 defaults
以下是我得到的结果:System start/stop links for /etc/init.d/tomcat7 already exist.
我已将其删除并重新添加,但没有任何变化。有人能帮助我吗?提前致谢。
答案1
检查一下是否相关:
在 Ubuntu 14.04 上通过 apt-get 安装 Tomcat7 失败
基本上,可能缺少一个依赖项(已用 修复sudo apt-get install libtomcat7-java
),但假设您已经这样做了,则 apt-get 包似乎通常是 FUBAR 并且需要安装后进行处理(通常我不推荐这样做,因为apt-get reconfigure
否则其他包命令可能会导致不良后果)。
因此,手动安装 .tgz(来自 Apache)可能是最稳定、阻力最小的路径。
答案2
问题出在您的系统变量上。
你已经CATALINA_HOME
定义了,但是没有CATALINA_BASE
,因此默认情况下它与相同CATALINA_HOME
,但这是不正确的。
CATALINA_BASE
:(可选)用于解析 Catalina 安装的动态部分的基本目录。如果不存在,则解析为 CATALINA_HOME 指向的同一目录。
通常你应该看到类似这样的内容:
# /usr/share/tomcat7/bin/catalina.sh run
Using CATALINA_BASE: /var/lib/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /tmp
Using JRE_HOME: /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Using CATALINA_PID: /var/run/tomcat7.pid
如果这些变量不存在,您可以手动定义它们:
. /etc/default/tomcat7
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 CATALINA_HOME=/usr/share/tomcat7 CATALINA_BASE=/var/lib/tomcat7 CATALINA_PID=/var/run/tomcat7.pid CATALINA_TMPDIR=/tmp
/usr/share/tomcat7/bin/catalina.sh run
或者正确配置你的/etc/init.d/tomcat7
启动脚本,因为通常它最后应该有这些变量:
# Directory where the Tomcat 6 binary distribution resides
CATALINA_HOME=/usr/share/$NAME
# Directory for per-instance configuration files and webapps
CATALINA_BASE=/var/lib/$NAME
检查内容以catalina.sh
了解更多详细信息,因为它描述了所有环境变量先决条件。
否则,重新安装您的 Tomcat。
答案3
我还遇到了目录问题。那是在我删除了 tomcat 7 并尝试重新安装它之后。不过,当我第一次删除它时,我没有触碰 libtomcat7-java 包。一旦我意识到可能是该包导致了问题,我就进行了完全删除并重新安装,然后 Tomcat 就出现了:
删除(这次确保包含 libtomcat7-java 包):
sudo apt-get remove --purge tomcat7 tomcat7-docs tomcat7-admin tomcat7-examples libtomcat7-java
重新安装:
sudo apt-get install tomcat7 tomcat7-docs tomcat7-admin tomcat7-examples libtomcat7-java
您首先会注意到的是 tomcat 会自行启动,不会出现任何问题。然后您可以继续正确配置它。