无法开始使用apache tomcat

时间:2013-02-24 17:28:29

标签: java apache tomcat7

我已经开始学习Servlet了,所以我从here下载了apache tomcat 7.x zip文件(core - > zip)。我将它解压缩到我的目录(D :),然后我将JAVA_HOME系统变量设置为值C:\Program Files\Java\jdk1.6.0(我的计算机正在 Windows 7上运行主页基本)。

我已通过bin文件夹中的 startup.bat 文件启动了服务器。当我尝试访问localhost:8080时,它总是在浏览器上显示unable to connect。所以我将端口号更改为 server.xml 中的9999并重新启动它。它再次说无法在我的浏览器中连接。当我启动服务器时,它在命令shell上显示以下内容。有人可以帮我解决这个问题,让我的服务器工作吗?

通过在命令shell上观察以下内容,我只能找到这一行,它似乎表明了问题: Failed to initialize component [Standard Server[8005]] 。我仍然不知道它与无法连接有什么关系..

Feb 24, 2013 4:58:02 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: C:\Program
Files\Java\jdk1.6.0\bin;.;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\
Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\
Program Files\Java\jdk1.6.0\bin
Feb 24, 2013 4:58:02 PM org.apache.catalina.startup.Catalina load
SEVERE: Catalina.start
org.apache.catalina.LifecycleException: Failed to initialize component [Standard
Server[8005]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: org.apache.catalina.LifecycleException: Failed to initialize componen
t [StandardService[Catalina]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.j
ava:814)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        ... 8 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize componen
t [StandardEngine[Catalina]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
        at org.apache.catalina.core.StandardService.initInternal(StandardService
.java:544)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        ... 10 more
Caused by: java.lang.NoSuchMethodError: java.util.concurrent.ThreadPoolExecutor.
allowCoreThreadTimeOut(Z)V
        at org.apache.catalina.core.ContainerBase.initInternal(ContainerBase.jav
a:1083)
        at org.apache.catalina.core.StandardEngine.initInternal(StandardEngine.j
ava:283)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        ... 12 more
Feb 24, 2013 4:58:02 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 532 ms
Feb 24, 2013 4:58:02 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-9999"]
Feb 24, 2013 4:58:02 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Feb 24, 2013 4:58:02 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Feb 24, 2013 4:58:03 PM org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
org.apache.catalina.LifecycleException: Failed to stop component [StandardServer
[8005]]
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:684)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Caused by: org.apache.catalina.LifecycleException: An invalid Lifecycle transiti
on was attempted ([before_stop]) for component [org.apache.catalina.deploy.Namin
gResources@1807ca8] in state [INITIALIZED]
        at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBas
e.java:409)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:219)
        at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.j
ava:756)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        ... 8 more
Feb 24, 2013 4:58:03 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11 ms

1 个答案:

答案 0 :(得分:0)

有一件事我注意到堆栈跟踪是这样的:

Caused by: java.lang.NoSuchMethodError: java.util.concurrent.ThreadPoolExecutor.allowCoreThreadTimeOut(Z)V

查看用于ThreadPoolExecutor的Javadoc,似乎在Java 6中引入了方法allowCoreThreatTimeOut(boolean)。它在早期版本中不存在。如果您在过时的JVM上运行为版本6+设计的java程序,上面的错误正是您所发现的。

当你第一次启动tomcat时,你应该有类似这样的行:

Using CATALINA_BASE:   /home/nick/tools/apache-tomcat-6.0.35
Using CATALINA_HOME:   /home/nick/tools/apache-tomcat-6.0.35
Using CATALINA_TMPDIR: /home/nick/tools/apache-tomcat-6.0.35/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/nick/tools/apache-tomcat-6.0.35/bin/bootstrap.jar

查看JRE_HOME的目录,看看你得到了什么。也许您已经安装了Tomcat尝试使用的Java 5,尽管命令行可以看到Java 6的安装。安装多个Java版本可能会造成混淆。