当前位置: 首页 > 知识库问答 >
问题:

Tomcat7 CentOS服务启动失败

宦烈
2023-03-14

我在自动加载tomcat7时遇到问题。这是init。d脚本:

#!/bin/bash
# chkconfig: 2345 80 20
# Description: Tomcat Server basic start/shutdown script
# /etc/init.d/tomcat7 -- startup script for the Tomcat 7 servlet engine

TOMCAT_HOME=/usr/local/tomcat7/bin
START_TOMCAT=/usr/local/tomcat7/bin/startup.sh
STOP_TOMCAT=/usr/local/tomcat7/bin/shutdown.sh

start() {
 echo -n "Starting tomcat7: "
 cd $TOMCAT_HOME
 ${START_TOMCAT}
 echo "done."
}

stop() {
 echo -n "Shutting down tomcat7: "
 cd $TOMCAT_HOME
 ${STOP_TOMCAT}
 echo "done."
}

case "$1" in

start)
 start
 ;;

stop)
 stop
 ;;

restart)
 stop
 sleep 10
 start
 ;;

*)
 echo "Usage: $0 {start|stop|restart}"

esac
exit 0

这样开始时:

>service tomcat7 start

Starting tomcat7: 
Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.
done.

Tomcat似乎无法从apache公共资源加载属性文件。有人知道这是为什么吗?

The file is:
user-config.properties
found in:
/usr/local/tomcat7/conf

直接运行时一切正常,如下所示:

/usr/local/tomcat7/bin/startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.

运行通过:

%%

%> ps -aux |grep tomcat
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root     26657 60.4  8.5 7181652 1385552 pts/0 Sl   16:11   0:15 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat7/endorsed -classpath /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat7 -Dcatalina.home=/usr/local/tomcat7 -Djava.io.tmpdir=/usr/local/tomcat7/temp org.apache.catalina.startup.Bootstrap start
root     26706  0.0  0.0 103252   844 pts/0    S+   16:11   0:00 grep tomcat

现在,我加载了导致错误的网页

HTTP Status 500 - java.lang.ExceptionInInitializerError
type Exception report
message java.lang.ExceptionInInitializerError
description The server encountered an internal error that prevented it from fulfilling this request.
exception

javax.servlet.ServletException: java.lang.ExceptionInInitializerErrorcom.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420)com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)javax.servlet.http.HttpServlet.service(HttpServlet.java:727)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)com.ftw.tme.filter.SessionFilter.doFilter(SessionFilter.java:130)

root cause

java.lang.ExceptionInInitializerErrorcom.ftw.tme.authentication.service.impl.AuthenticationServiceImpl.<init>(AuthenticationServiceImpl.java:27)com.ftw.tme.rest.AuthenticationRestService.<init>(AuthenticationRestService.java:38)sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)java.lang.reflect.Constructor.newInstance(Constructor.java:526)com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:245)com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:233)com.sun.jersey.server.impl.resource.PerRequestFactory$PerRequest._getInstance(PerRequestFactory.java:182)com.sun.jersey.server.impl.resource.PerRequestFactory$AbstractPerRequest.getInstance(PerRequestFactory.java:144)com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationContext.java:239)com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)javax.servlet.http.HttpServlet.service(HttpServlet.java:727)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)com.ftw.tme.filter.SessionFilter.doFilter(SessionFilter.java:130)

root cause

java.lang.NullPointerExceptionjava.lang.String.replace(String.java:2180)com.ftw.tme.commons.db.util.tmeConfigUtils.<clinit>(tmeConfigUtils.java:71)com.ftw.tme.authentication.service.impl.AuthenticationServiceImpl.<init>(AuthenticationServiceImpl.java:27)com.ftw.tme.rest.AuthenticationRestService.<init>(AuthenticationRestService.java:38)sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)java.lang.reflect.Constructor.newInstance(Constructor.java:526)com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:245)com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:233)com.sun.jersey.server.impl.resource.PerRequestFactory$PerRequest._getInstance(PerRequestFactory.java:182)com.sun.jersey.server.impl.resource.PerRequestFactory$AbstractPerRequest.getInstance(PerRequestFactory.java:144)com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationContext.java:239)com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)javax.servlet.http.HttpServlet.service(HttpServlet.java:727)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)com.ftw.tme.filter.SessionFilter.doFilter(SessionFilter.java:130)






%> ps -aux |grep tomcat
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root     26657 19.2  8.6 7718532 1397424 pts/0 Sl   16:11   0:15 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat7/endorsed -classpath /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat7 -Dcatalina.home=/usr/local/tomcat7 -Djava.io.tmpdir=/usr/local/tomcat7/temp org.apache.catalina.startup.Bootstrap start
root     26727  0.0  0.0 103252   844 pts/0    S+   16:12   0:00 grep tomcat
[user@localhost bin]# 

共有1个答案

程赞
2023-03-14

在您自己的代码中看起来像NPE:

root cause

java.lang.NullPointerException
  java.lang.String.replace(String.java:2180)
  com.ftw.tme.commons.db.util.tmeConfigUtils.<clinit>(tmeConfigUtils.java:71)
  com.ftw.tme.authentication.service.impl.AuthenticationServiceImpl.<init>(AuthenticationServiceImpl.java:27)
  com.ftw.tme.rest.AuthenticationRestService.<init>(AuthenticationRestService.java:38)
 类似资料:
  • 而且我也无法在windows serice中启动neo4j服务。也许以前有人遇到过这个案子?

  • 我正在使用Vagrant部署到Ubuntu Linux,并尝试启动服务。 然后我跟踪,发现: ?tomcat8.service-lsb:启动tomcat。加载:加载(/etc/init.d/tomcat8) active:失败(结果:exit-code)自2016-03-28 09:44:17 GMT;5s前 文档:人:systemd-sysv-generator(8) 进程:884 execst

  • 尝试远程启动服务时遇到奇怪的行为。 编辑:我进一步研究了这个问题,发现只有在尝试运行我的特定服务时才会出现这种情况。这意味着我的服务必须从已经登录的用户的会话中运行(这就是为什么如果我之前使用mstsc访问服务器,它仍然可以工作)。所以我想我的新问题是--有没有一种方法可以让我从PowerShell登录到远程机器? 多谢了。

  • 链接到问题:https://github.com/jenca-cloud/docker-bimserver/issues/1 指向DockerFile的链接:https://hub.docker.com/r/connoralexander/docker-bimserver/ 大家好,我有一个问题是Tomcat8没有启动服务。正在使用设置的用户名和密码成功安装Tomcat 8.0.30。它成功地wg

  • 问题内容: 从我在Stack Exchange和其他地方看到的所有内容中,我已经正确设置了所有内容,可以在启动Android OS时启动IntentService。不幸的是,它没有在启动时启动,并且我没有收到任何错误。也许专家可以帮忙… 表现: 用于启动的BroadcastReceiver: 更新:我尝试了下面的几乎所有建议,并;在处理程序中添加了日志记录,但从未记录过任何内容。因此,它甚至还没有

  • 问题内容: 我使用以下命令在Cnetos 7上安装了jenkins: 如官方文档中所述 但是当我运行时: 我收到以下错误消息: 跑步给了我这个: 跑步给了我这个: 两者都真的无济于事。如何解决此问题? 问题答案: 在Ubuntu 16.04上类似的问题。 要解决此问题,请手动安装Java Runtime Environment: JDK版本9: JDK版本8: 打开Jenkins配置文件: 最后,