2

我已经开始学习 Servlets,所以我从这里下载了 apache tomcat 7.x zip 文件(core--> zip) 。我将它解压缩到我的目录 (D:),然后我刚刚将JAVA_HOMESystem 变量设置为值C:\Program Files\Java\jdk1.6.0(我的计算机在windows 7 Home basic 上运行)。

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

通过在命令 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
4

1 回答 1

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 版本可能会导致混淆。

于 2013-02-25T09:59:24.470 回答