在 Eclipse 3.4.2 中调试一个 tomcat 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/663769/
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-09-10 18:39:54  来源:igfitidea点击:

Debugging a tomcat project in Eclipse 3.4.2

eclipsetomcatpluginsdebuggingeclipse-wtp

提问by Dipesh

I downloaded eclipse 3.4.2 and tried installing tomcat plugin (version 3.2.1)for eclipse from sysdeo (http://www.eclipsetotale.com/tomcatPlugin.html)

我下载了 eclipse 3.4.2 并尝试从 sysdeo ( http://www.eclipsetotale.com/tomcatPlugin.html)为 eclipse 安装 tomcat 插件(版本 3.2.1 )

I have followed installation instructions but when is start tomcat from eclipse toolbar i got the following error

我已按照安装说明进行操作,但是从 eclipse 工具栏启动 tomcat 时出现以下错误

java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/SystemLogHandler at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class.getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:205) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:390)

java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/SystemLogHandler at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class .getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) at org.apache.catalina.startup.Bootstrap。 init(Bootstrap.java:205) 在 org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:390)

I did follow troubleshoot instructions but no success.

我确实按照故障排除说明进行了操作,但没有成功。

I tried to putting plugin in dropin directory too but still got the same error.

我也尝试将插件放在 dropin 目录中,但仍然出现相同的错误。

This was working fine in eclipse 3.2 and 3.3

这在 eclipse 3.2 和 3.3 中运行良好

Then I tried using standard inbuilt WTP to set up my tomcat server. I am not sure how it will pick my server.xml in conf directory of tomcat, it seems it is not picking as of now. How do I associate my eclipse project with this setup. I am able to start the server but when i browse the tomcat start page, it does not show anything.

然后我尝试使用标准的内置 WTP 来设置我的 tomcat 服务器。我不确定它会如何在 tomcat 的 conf 目录中选择我的 server.xml,目前似乎还没有选择。如何将我的 eclipse 项目与此设置相关联。我能够启动服务器,但是当我浏览 tomcat 起始页时,它没有显示任何内容。

I would appreciate if someone can provide some ways to fix this.

如果有人能提供一些方法来解决这个问题,我将不胜感激。

Thanks in advance.

提前致谢。

-Dipesh

-迪佩什

回答by Dipesh

After trying out few things I was able to debug tomcat project in eclipse 3.4.2 To debug tomcat application/project using eclipse 3.4.2 use WTP plugins which are installed along with it.

在尝试了几件事之后,我能够在 eclipse 3.4.2 中调试 tomcat 项目要使用 eclipse 3.4.2 调试 tomcat 应用程序/项目,请使用随它安装的 WTP 插件。

Go to Window --> Show View --> Others --> Server

转到窗口 --> 显示视图 --> 其他 --> 服务器

In this view create a new server, please select tomcat installation directory and version information.

在此视图中新建服务器,请选择tomcat安装目录和版本信息。

Then double click on Tomcat VX.X Server at local host, it opens up configuration settings page

然后双击本地主机上的Tomcat VX.X Server,打开配置设置页面

In the Server Locations Section select "Use Tomcat Installation (takes control of Tomcat Installation) and enter deploy path.

在服务器位置部分选择“使用 Tomcat 安装(控制 Tomcat 安装)”并输入部署路径。

In the publishing section select Never Publish automatically and uncheck update context path checkbox.

在发布部分选择从不自动发布并取消选中更新上下文路径复选框。

Voila!! All set to debug tomcat project in eclipse 3.4.2

瞧!!全部设置为在 Eclipse 3.4.2 中调试 tomcat 项目

There is no need to download and copy any extra plugin.

无需下载和复制任何额外的插件。

Thanks Juri. Hope this helps.

谢谢尤里。希望这可以帮助。

回答by Juri

I'm using Tomcat with Eclipse Java EE version with WTP and it works perfectly. I have Ant scripts which deploy my web app to the tomcat webapp folder. In order to debug, you have to open the Server view in Eclipse, add a new server and choose the correct Tomcat version. Once that's done, open the configuration of Tomcat within eclipse by double-clicking on the server entry in the Eclipse server view you just created. On the left-middle side of the confguration page you should see something like "let Eclipse control the native Tomcat installation", I don't remember the exact text now. You have to choose that. Then you can set a breakpoint in your source code and then start Tomcat in debug mode from within Eclipse's server view. Hope that helped.

我将 Tomcat 与 Eclipse Java EE 版本与 WTP 一起使用,它运行良好。我有将我的 web 应用程序部署到 tomcat webapp 文件夹的 Ant 脚本。为了调试,您必须在 Eclipse 中打开服务器视图,添加新服务器并选择正确的 Tomcat 版本。完成后,通过双击刚刚创建的 Eclipse 服务器视图中的服务器条目,在 eclipse 中打开 Tomcat 的配置。在配置页面的左中侧,您应该会看到类似“让 Eclipse 控制本机 Tomcat 安装”之类的内容,我现在不记得确切的文字了。你必须选择那个。然后,您可以在源代码中设置断点,然后从 Eclipse 的服务器视图中以调试模式启动 Tomcat。希望有所帮助。

回答by Juri

If you are using the Sysdeo plugin, then you don'twant to also be using the standard Eclipse WTP servers. To use the Sysdeo plugin, you need to have already downloaded and extracted a standard zipped tomcat directory. Make sure to define CATALINA_HOME in your path. Then, assuming you've correctly installed the sysdeo plugin, go into Eclipse->Windows->Prefs->Tomcat (this is Sysdeo's Tomcat settings, and not the WTP settings). You need to tell the plugin where you've extracted your Tomcat directory, and set it to use Context files.

如果您正在使用 Sysdeo 插件,那么您希望也使用标准的 Eclipse WTP 服务器。要使用 Sysdeo 插件,您需要已经下载并解压缩标准的压缩 tomcat 目录。确保在您的路径中定义 CATALINA_HOME。然后,假设您已经正确安装了 sysdeo 插件,进入 Eclipse->Windows->Prefs->Tomcat(这是 Sysdeo 的 Tomcat 设置,而不是 WTP 设置)。您需要告诉插件您将 Tomcat 目录解压缩到何处,并将其设置为使用上下文文件。

Now create a new Dynamic web project. Right click it, and go into its properties->Tomcat. Check it as a 'Tomcat Project'. Give it a context name, and also tell it the directory which would be the base of your war (by default, Eclipse has named this WebContent, I believe). Apply it and close the Window. Right click again your project, and go to the Tomcat section. Add the 'Tomcat Libraries to Build Path' so you can use the Servlet/JSP classes. Finally, click on 'Update Context'. If you go into your Tomcat directory under Conf, you'll see that the plugin has created a context for you that points to your Eclipse workspace. No need for deploying the app to the Tomcat directory. Now, you should be able to click on the Sysdeo Tomcat 'start' button, and your app should be able to connect to your app at localhost:8080/context_name.

现在创建一个新的动态 Web 项目。右键单击它,然后进入其属性->Tomcat。将其作为“Tomcat 项目”进行检查。给它一个上下文名称,并告诉它作为War基础的目录(默认情况下,Eclipse 已经命名了这个 WebContent,我相信)。应用它并关闭窗口。再次右键单击您的项目,然后转到 Tomcat 部分。添加“Tomcat 库到构建路径”,以便您可以使用 Servlet/JSP 类。最后,单击“更新上下文”。如果您进入 Conf 下的 Tomcat 目录,您将看到该插件已为您创建了一个指向 Eclipse 工作区的上下文。无需将应用程序部署到 Tomcat 目录。现在,您应该可以单击 Sysdeo Tomcat 的“开始”按钮,并且您的应用程序应该能够在 localhost 连接到您的应用程序:

HTH, Bill

HTH,比尔

回答by nzpcmad

Using the excellent Findjarweb page for:

使用优秀的Findjar网页:

org/apache/tomcat/util/log/SystemLogHandler

org/apache/tomcat/util/log/SystemLogHandler

gives the following:

给出以下内容:

Information on class org.apache.tomcat.util.log.SystemLogHandler:

关于 org.apache.tomcat.util.log.SystemLogHandler 类的信息:

Containing JAR files:
jbossweb.jar
gwt-dev-windows.jar
tomcat-util-3.3.2.jar
tomcat-util-4.0.6.jar
tomcat-util-4.1.31.jar
tomcat-util-4.1.34.jar
tomcat-util-4.1.36.jar
tomcat-util-5.0.16.jar
tomcat-util-5.0.18.jar
tomcat-util-5.0.28.jar
tomcat-util-5.5.12.jar
tomcat-util-5.5.15.jar
tomcat-util-5.5.23.jar
tomcat-util-5.5.4.jar
tomcat-util-5.5.7.jar
tomcat-util-5.5.9.jar
tomcat-util-5.5.7-alpha.jar
tomcat-util-5.5.8-alpha.jar
tomcat-util-5.5.9-alpha.jar

包含JAR文件:
jbossweb.jar
gwt-dev-windows.jar
tomcat-util-3.3.2.jar
tomcat-util-4.0.6.jar
tomcat-util-4.1.31.jar
tomcat-util-4.1.34.jar
tomcat-util-4.1.36.jar
tomcat-util-5.0.16.jar
tomcat-util-5.0.18.jar
tomcat-util-5.0.28.jar
tomcat-util-5.5.12.jar
tomcat-util-5.5 .15.jar
tomcat-util-5.5.23.jar
tomcat-util-5.5.4.jar
tomcat-util-5.5.7.jar
tomcat-util-5.5.9.jar
tomcat-util-5.5.7-alpha。 jar
tomcat-util-5.5.8-alpha.jar
tomcat-util-5.5.9-alpha.jar

Ensure the appropriate jar file is in your CLASSPATH.

确保适当的 jar 文件在您的 CLASSPATH 中。