Java 无法找到或加载主类 org.apache.catalina.startup.Bootstrap

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31029810/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 10:32:34  来源:igfitidea点击:

Could not find or load main class org.apache.catalina.startup.Bootstrap

javaeclipsetomcat7

提问by Nitesh Kataria

When I run apache tomcat7.0.56 in Eclipse, I get an error

当我在 Eclipse 中运行 apache tomcat7.0.56 时,出现错误

Error: Could not find or load main class org.apache.catalina.startup.Bootstrap

错误:无法找到或加载主类 org.apache.catalina.startup.Bootstrap

How can I fix the problem?

我该如何解决这个问题?

回答by michael

After installing tomcat, start eclipse and configure and/or verify tomcat is correctly set up in eclipse: Go to "Servers" ("Window", "Show View", "Servers"), right-click on "Servers", and add the path to (e.g.) Tomcat7.0.56.... For reference, see this tutorial.

安装 tomcat 后,启动 eclipse 并在 eclipse 中配置和/或验证 tomcat 是否正确设置:转到“服务器”(“窗口”、“显示视图”、“服务器”),右键单击“服务器”,然后添加到(例如)Tomcat7.0.56 的路径......供参考,请参阅本教程

If you've configured eclipse to run tomcat as a normal java application (i.e,. specifying the main class), then see these steps; but this approach may be an unnecessarily complicated for your use case.

如果您已将 eclipse 配置为将 tomcat 作为普通 Java 应用程序运行(即,指定主类),请参阅以下步骤;但是对于您的用例来说,这种方法可能会不必要地复杂化。

回答by Facepalmed

First of all you should try to run TOMCAT using it's own .bat and not Eclipse. If it doesn't run problems would be on your tomcat installation and not in Eclipse and you could take a look to the files of TOMCAT_HOME/logs/ where Tomcat's errors are traced (they are so helpful).

首先,您应该尝试使用它自己的 .bat 而不是 Eclipse 来运行 TOMCAT。如果它没有运行问题将在您的 tomcat 安装上而不是在 Eclipse 中,您可以查看 TOMCAT_HOME/logs/ 的文件,其中跟踪了 Tomcat 的错误(它们非常有用)。

Anyway, if it runs properly out of eclipse, try to delete the eclipse's tomcat configuration and set it from the beginning following these simple steps

无论如何,如果它在eclipse之外正常运行,请尝试删除eclipse的tomcat配置并按照以下简单步骤从头开始设置

  • Go to Eclipse's Window > Preferences > Server > Runtime Environmentand add a Tomcat Server browsing your TOMCAT_HOME and selecting the suitable JRE (use JAVA_HOME that contains jre yet) paying attention to messages requiring a certain JDK depending on the TOMCAT version (TOMCAT_8 requires at least JDK_1.7 version and, if not set, usually shows errors explaining it when starting)
  • Go to Eclipse's Window > Show View > Other... > Server > Serversand add a new server; in this case the version of TOMCAT you set before. You don't need to add further configuration to make TOMCAT to start.
  • At this point if would be helpful if you hadn't any app at TOMCAT_HOME's webapps folder but those that came default (you must empty TOMCAT_HOME/work folder to remove cached stuff). Once you have ensured it, start from ECLIPSE and cross fingers. In case of fail, take a look to Eclipse's console and look for the exception to copy at this post
  • 转到 Eclipse 的Window > Preferences > Server > Runtime Environment并添加一个 Tomcat 服务器,浏览您的 TOMCAT_HOME 并选择合适的 JRE(使用包含 jre 的 JAVA_HOME)注意根据 TOMCAT 版本需要特定 JDK 的消息(TOMCAT_8 至少需要JDK_1.7 版本,如果未设置,通常会在启动时显示错误解释)
  • 转到 Eclipse 的Window > Show View > Other... > Server > Servers并添加一个新服务器;在这种情况下,您之前设置的 TOMCAT 版本。您不需要添加进一步的配置来启动 TOMCAT。
  • 在这一点上,如果您在 TOMCAT_HOME 的 webapps 文件夹中没有任何应用程序,而是那些默认的应用程序(您必须清空 TOMCAT_HOME/work 文件夹以删除缓存的内容),这将有所帮助。确定后,从 ECLIPSE 开始并交叉手指。如果失败,请查看 Eclipse 的控制台并在此帖子中查找要复制的异常

回答by lumpynose

I was having the same problem, Windows 10 64 bit, Eclipse Neon.2 4.6.2.

我遇到了同样的问题,Windows 10 64 位,Eclipse Neon.2 4.6.2。

Newly extracted tomcat zip, 8.5.11. Had done the stuff that michael_n said (multiple times with different versions of tomcat).

新提取的 tomcat zip,8.5.11。已经完成了michael_n所说的事情(多次使用不同版本的tomcat)。

What fixed it for me was in the dzone article the part about setting the Run Directory in the Run Configuration under Arguments. I set it to the top tomcat directory (the one with bin, lib, etc. in it) That's the only thing I did and then it starts and I can go to the main tomcat page.

为我修复的是 dzone 文章中关于在参数下的运行配置中设置运行目录的部分。我将它设置到顶级 tomcat 目录(其中包含 bin、lib 等的目录)这是我所做的唯一一件事,然后它启动,我可以转到主 tomcat 页面。

But it's not running my app; it's not listed in the manager.

但它没有运行我的应用程序;它没有列在管理器中。

回答by Shekhar Kadam

Que 1. Is your tomcat started interdependently(outside eclipse)??

Que 1. 你的tomcat是相互依赖启动的吗(在eclipse之外)??

Ans. if ans is no - then - I think you have downloaded tomcat source instead binary... you should download binary and install tomcat then it will run.

答。如果 ans 不是 - 那么 - 我认为你已经下载了 tomcat 源代码而不是二进制文件......你应该下载二进制文件并安装 tomcat 然后它会运行。

1.download binary (https://tomcat.apache.org/) 2.unzip it

1.下载二进制文件(https://tomcat.apache.org/) 2.解压

3.copy unzipped apache folder

3.copy解压后的apache文件夹

4.place this to your program files

4.将其放置到您的程序文件中

  1. set JAVA_HOME to C:\Program Files\Java\jdk_Your_version_num

  2. Run C:\Program Files\apache-tomcat-Your_version_num\bin\startup.bat .... hope your tomcat will start

  1. 将 JAVA_HOME 设置为 C:\Program Files\Java\jdk_Your_version_num

  2. 运行 C:\Program Files\apache-tomcat-Your_version_num\bin\startup.bat .... 希望你的 tomcat 能启动

1.download binary Link -. https://tomcat.apache.org/

1.下载二进制链接-。https://tomcat.apache.org/

1.1. choose version of your choice and click "download"

1.1. 选择您选择的版本并点击“下载”

1.2. On next page under heading "Binary Distributions"- download zip and proceed to next steps. All the best.

1.2. 在下一页标题“二进制分发”下 - 下载 zip 并继续下一步。祝一切顺利。

回答by Rahul Kanchi

If tomcat is working perfectly fine independently,

如果 tomcat 独立工作得很好,

  • then change the permissions of the directory and subdirectories of tomcat
  • 然后更改tomcat的目录和子目录的权限

Eclipse is not able to read a certain file from the directory which is the reason for the error. Nothing worked for me, but changing the permission helped me.

Eclipse 无法从目录中读取某个文件,这是导致错误的原因。没有什么对我有用,但更改许可对我有帮助。