2

我发现了与此类似的其他堆栈溢出问题。答案似乎是针对那些人的错误,所以我放弃了。

我记得,当我停止这个项目时,我没有这个错误。在我回到这个项目并得到这个错误之前,我不记得有任何改变。

我想在本地 tomcat 8.5 服务器上调试我的 web 应用程序。在 Eclipse IDE for Enterprise Java Developers 版本 2019-03(4.11.0) 中,我右键单击我的 Web 项目并选择 Debug As->Debug on Server。出现一个对话框,我选择手动定义新服务器选项。我选择 Tomcat v8.5 服务器。我单击完成按钮。调试窗口中出现一些红色文本。然后出现一个对话框说:

“在 localhost 启动 Tomcat v8.5 服务器”遇到了问题。

本地主机上的服务器 Tomcat v8.5 服务器无法启动。

我已经能够成功地用startup.sh启动tomcat,并且已经能够成功地用shutdown.sh关闭tomcat,所以我知道tomcat可以自己工作。

我可以在 AWS Beanstalk 上运行这个 Web 项目。

这是它在调试窗口中所说的:

Jan 31, 2020 9:54:37 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.5.41
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          May 4 2019 09:17:16 UTC
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.5.41.0
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Mac OS X
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.14.6
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          x86_64
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_211-b12
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /Users/shinehah/eclipse-workspaces/eclipse-java-ee-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /Users/shinehah/tomcat/apache-tomcat-8.5.41
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:56586
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -javaagent:/Users/shinehah/eclipse/jee-2019-03-3/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/402/0/.cp/lib/javaagent-shaded.jar
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/Users/shinehah/eclipse-workspaces/eclipse-java-ee-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/Users/shinehah/tomcat/apache-tomcat-8.5.41
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/Users/shinehah/eclipse-workspaces/eclipse-java-ee-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/Users/shinehah/tomcat/apache-tomcat-8.5.41/endorsed
Jan 31, 2020 9:54:37 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Jan 31, 2020 9:54:37 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/shinehah/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
Jan 31, 2020 9:54:38 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jan 31, 2020 9:54:38 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jan 31, 2020 9:54:38 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Jan 31, 2020 9:54:38 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jan 31, 2020 9:54:38 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1816 ms
Jan 31, 2020 9:54:38 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Jan 31, 2020 9:54:38 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.41
Jan 31, 2020 9:54:39 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jan 31, 2020 9:54:39 AM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webproject10]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:882)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webproject10]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Realm[MemoryRealm]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5113)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Memory database file [/usr/share/tomcat8/webapps/ROOT/WEB-INF/tomcat-users.xml] cannot be read
    at org.apache.catalina.realm.MemoryRealm.startInternal(MemoryRealm.java:276)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 8 more
Caused by: java.io.FileNotFoundException: /usr/share/tomcat8/webapps/ROOT/WEB-INF/tomcat-users.xml (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at org.apache.tomcat.util.file.ConfigFileLoader.getInputStream(ConfigFileLoader.java:89)
    at org.apache.catalina.realm.MemoryRealm.startInternal(MemoryRealm.java:258)
    ... 9 more

Jan 31, 2020 9:54:39 AM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:688)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:882)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webproject10]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
    ... 8 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webproject10]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Realm[MemoryRealm]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5113)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Memory database file [/usr/share/tomcat8/webapps/ROOT/WEB-INF/tomcat-users.xml] cannot be read
    at org.apache.catalina.realm.MemoryRealm.startInternal(MemoryRealm.java:276)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 8 more
Caused by: java.io.FileNotFoundException: /usr/share/tomcat8/webapps/ROOT/WEB-INF/tomcat-users.xml (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at org.apache.tomcat.util.file.ConfigFileLoader.getInputStream(ConfigFileLoader.java:89)
    at org.apache.catalina.realm.MemoryRealm.startInternal(MemoryRealm.java:258)
    ... 9 more

Jan 31, 2020 9:54:39 AM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:688)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
    ... 13 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:882)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webproject10]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
    ... 8 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webproject10]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Realm[MemoryRealm]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5113)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Memory database file [/usr/share/tomcat8/webapps/ROOT/WEB-INF/tomcat-users.xml] cannot be read
    at org.apache.catalina.realm.MemoryRealm.startInternal(MemoryRealm.java:276)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 8 more
Caused by: java.io.FileNotFoundException: /usr/share/tomcat8/webapps/ROOT/WEB-INF/tomcat-users.xml (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at org.apache.tomcat.util.file.ConfigFileLoader.getInputStream(ConfigFileLoader.java:89)
    at org.apache.catalina.realm.MemoryRealm.startInternal(MemoryRealm.java:258)
    ... 9 more

Jan 31, 2020 9:54:39 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Jan 31, 2020 9:54:39 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-nio-8009"]
Jan 31, 2020 9:54:39 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service [Catalina]
Jan 31, 2020 9:54:39 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-nio-8080"]
Jan 31, 2020 9:54:39 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-nio-8009"]

在“问题”窗格中,我看到以下 4 个错误:

Cannot change version of project facet Dynamic Web Module to 3.1.
JavaServer Faces 2.2 can not be installed : One or more constraints have not been satisfied.
JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer.
One or more constraints have not been satisfied.
4

4 回答 4

2

在 Eclipse WTP 中运行 Tomcat 有多种不同的方式,这些方式在“服务器位置”部分中配置,如下所示:

在此处输入图像描述

从您的日志中,您现在应该使用第一个选项(即使用工作区元数据(不修改 Tomcat 安装)),Eclipse 会将 Tomcat 作为一个单独的实例运行,其根文件夹位于配置的“服务器路径”(即$project_workspace /.metadata/.plugins/org.eclipse.wst.server.core/tmp3在这个例子中)。

请注意,这个 Tomcat 实例与您startup.sh从命令行使用的启动 Tomcat 不同。它们具有不同的配置设置。您应该注意到在定义服务器后也创建了一个服务器项目。该项目包含 Eclipse 运行的这个 tomcat 实例的配置。

在此处输入图像描述

所以server.xml在这个 Server 项目中打开并找到MemoryRealm. 我相信你在这里设置了一个无效的pathname,这会导致这个问题。因此,请尝试更正它或简单地删除它,例如它将使用默认设置,该设置将引用tomcat-users.xml服务器项目中的 。

另一方面,您可以尝试使用第二个选项(使用 Tomcat 安装(控制 Tomcat 安装))。然后,Eclipse 将运行 Tomcat,就像您使用startup.sh它一样运行它,我相信它应该可以正常工作,因为您提到它能够以startup.sh.

于 2020-02-12T05:57:31.047 回答
2

当您的项目的某些 Jar 文件或其他依赖相关文件损坏时,就会发生这种情况。当我遇到同样的异常时,我正在做一个小项目。我删除了与项目相关的所有依赖项并重新安装了它们。它开始为我工作。希望这可以帮助!

于 2020-02-18T12:05:49.890 回答
0

通常开发人员首先在服务器选项卡上定义服务器,然后在服务器上运行调试

另外我怀疑您在 Eclipse 中的项目类型不正确。我建议你检查项目类型。

于 2020-02-13T02:04:42.840 回答
0

我在我的 Eclipse 中检查了一个 Web 应用程序,它也在 tomcat 8.5 中运行。tomcat-users.xml 路径是 [myworkspace]\Servers\Tomcat v8.5 Server at localhost-config

您能否尝试以下步骤:

  1. 下载一个全新的tomcat8.5并安装到一个新文件夹中
  2. 为您的项目创建一个全新的工作区。
  3. 转到eclipse“服务器”视图,单击该链接以添加服务器
  4. 在里面选择 Apache tomcat 8.5
  5. 选择新的tomcat安装文件夹
  6. 将您的 Web 应用程序添加到其中
  7. 右键单击您新添加的服务器并选择“开始”

在这些步骤中,我没有发现任何问题。你能试试吗?

于 2020-02-12T04:20:08.040 回答