tomcat启动失败的常见原因

Posted 旮旯风行

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat启动失败的常见原因相关的知识,希望对你有一定的参考价值。

tomcat启动失败的常见原因

 

 

根据不同情况,笔者碰到过的有以下几种情况:

1. 运行tomcat的启动文件startup.bat,弹出黑窗口,直接闪退。

    这种情况一般都是没有配置JAVA_HOME导致的,配置jdk如果没有使用JAVA_HOME的方式配置环境变量,就会出这种问题

2. 启动后,停留一段时间,打印一些日志,然后窗口关闭。

  这种情况一般是端口号冲突了。

  由于端口号只会支持一个程序运行,如果tomcat的默认端口号被其他程序占用,就会导致冲突。解决这种问题的手段分为两种,第一,关闭占用默认端口号的程序(不太建议),第二,修改tomcat使用的默认端口号。

  关闭占用默认端口号的程序

       如果选择结束掉占用了默认端口号的程序,如何查看是哪个程序占用了端口号呢?

  在cmd命令输入netstat -aov

本地地址最右侧就是已经被使用的端口号,找到默认端口号8080,记下最右侧的数字(PID的值)

接着打开任务管理器,找到和PID值匹配的进程,将其关闭即可(默认情况下,任务管理器不会显示PID,需要手动开启PID显示)

修改tomcat使用的默认端口号

在TomCat文件目录下找到conf文件下的server.xml文件

修改上图的8080即可。

3. 运行tomcat后,tomcat很快就启动完成了,但是日志打印了一大堆严重。

    这种情况,似乎是因为tomcat的权限不足导致的,需要提升tomcat的权限,只需要修改tomcat中的config文件夹的权限,将权限改成完全控制,如下图(要注意,一定要修改电脑当前登录用户下的权限,否则没用,在下图中的组或用户名中找到当前登录的用户。)

发一下,这种情况报的错误信息。

信息: Loaded APR based Apache Tomcat Native library 1.1.14.
2009-5-25 7:55:48 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], random [true].
2009-5-25 7:55:50 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2009-5-25 7:55:50 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2009-5-25 7:55:50 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 3594 ms
2009-5-25 7:55:50 org.apache.naming.NamingContext lookup
警告: Unexpected exception resolving reference
java.io.IOException: Cannot rename original file to C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/tomcat-users.xml.old
 at org.apache.catalina.users.MemoryUserDatabase.save(MemoryUserDatabase.java:582)
 at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:104)
 at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
 at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
 at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
 at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
 at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:137)
 at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:109)
 at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:81)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:703)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-5-25 7:55:50 org.apache.catalina.mbeans.GlobalResourcesLifecycleListener createMBeans
严重: Exception processing Global JNDI Resources
javax.naming.NamingException: Cannot rename original file to C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/tomcat-users.xml.old
 at org.apache.naming.NamingContext.lookup(NamingContext.java:805)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
 at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
 at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
 at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:137)
 at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:109)
 at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:81)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:703)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-5-25 7:55:50 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-5-25 7:55:50 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.18
2009-5-25 7:55:50 org.apache.naming.NamingContext lookup
警告: Unexpected exception resolving reference
java.io.IOException: Cannot rename original file to C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/tomcat-users.xml.old
 at org.apache.catalina.users.MemoryUserDatabase.save(MemoryUserDatabase.java:582)
 at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:104)
 at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
 at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
 at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:253)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-5-25 7:55:50 org.apache.catalina.realm.UserDatabaseRealm start
严重: Exception looking up UserDatabase under key UserDatabase
javax.naming.NamingException: Cannot rename original file to C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/tomcat-users.xml.old
 at org.apache.naming.NamingContext.lookup(NamingContext.java:805)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
 at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:253)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-5-25 7:55:50 org.apache.catalina.startup.Catalina start
严重: Catalina.start: 
LifecycleException:  No UserDatabase component found under key UserDatabase
 at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:261)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-5-25 7:55:50 org.apache.catalina.startup.Catalina start
信息: Server startup in 299 ms

以上是关于tomcat启动失败的常见原因的主要内容,如果未能解决你的问题,请参考以下文章

tomcat下服务启动失败原因

技术分享 MySQL 启动失败的常见原因

eclipse中Tomcat启动失败 都有哪些原因

Tomcat启动失败的常见问题

Tomcat启动失败的常见问题

Tomcat启动失败的常见问题