Eclipse 中的 Tomcat - 从启用 JPDA 开始

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

Tomcat within Eclipse - starting with JPDA enabled

eclipsetomcatjpda

提问by Dave

I'm trying to get a webapp up and running - for debugging - within a Tomcat instance configured in Eclipse (to keep my work flow as automatic as possible). I'm trying to get remote debugging enabled within the Tomcat JVM, and I've read about two sets of VM arguments:

我正在尝试在 Eclipse 中配置的 Tomcat 实例中启动并运行 web 应用程序 - 用于调试(以保持我的工作流程尽可能自动化)。我正在尝试在 Tomcat JVM 中启用远程调试,并且我已经阅读了两组 VM 参数:

-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n

or..

或者..

-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

But whenever I attempt to use either of these, I get an error message in my console:

但是每当我尝试使用其中任何一个时,我都会在控制台中收到一条错误消息:

Error occurred during initialization of VM
agent library failed to init: jdwp
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.

初始化 VM
代理库期间发生错误 无法初始化:jdwp
错误:无法两次加载此 JVM TI 代理,请检查您的 java 命令行是否有重复的 jdwp 选项。

I don't know where I should be looking for these other - supposedly duplicate - jdwp options. Where are these configured? How can I get this working?

我不知道我应该在哪里寻找这些其他 - 据说是重复的 - jdwp 选项。这些是在哪里配置的?我怎样才能让它工作?

回答by Kris Babic

If you've correctly setup Tomcat to be started and stopped inside an Eclipse instance, then you should not have to manually setup the debug options for the server to debug your application from inside of Eclipse. When you start Tomcat in debug mode from within Eclipse, the debug options are automatically added to the startup process. By manually configuring them in the launch configuration you are causing a duplication of the settings, thus the error response.

如果您已正确设置 Tomcat 在 Eclipse 实例中启动和停止,那么您就不必手动设置服务器的调试选项来从 Eclipse 内部调试您的应用程序。当您从 Eclipse 中以调试模式启动 Tomcat 时,调试选项会自动添加到启动过程中。通过在启动配置中手动配置它们,您会导致设置重复,从而导致错误响应。

To verify that you have setup the server correctly, here are some steps to setup Tomcat in the Helios release:

为了验证您是否正确设置了服务器,以下是在 Helios 版本中设置 Tomcat 的一些步骤:

  • If your Servers view is not open, go to Window->Show View->Servers
  • Right-click the servers window and select New->Server
  • In the 'Select the server type' window select the Tomcat version you are setting up
  • Select next (if already configured the server runtime environment, then 'Finish' button will be available)
  • Enter server name and installation directory for your environment
  • select 'Finish'
  • 如果您的服务器视图未打开,请转到窗口->显示视图->服务器
  • 右键单击服务器窗口并选择新建->服务器
  • 在“选择服务器类型”窗口中选择您正在设置的 Tomcat 版本
  • 选择下一步(如果已经配置了服务器运行环境,则“完成”按钮将可用)
  • 为您的环境输入服务器名称和安装目录
  • 选择“完成”

At this point, you should be able to see your newly setup Tomcat instance in your Servers window. At this point you can deploy your application to the newly setup server. To start the server in debug mode, you can select the debug botton available from the Servers window. Once the server starts the IDE will be automatically connected to allow for debugging your deployed application.

此时,您应该能够在 Servers 窗口中看到新设置的 Tomcat 实例。此时,您可以将应用程序部署到新设置的服务器。要以调试模式启动服务器,您可以从“服务器”窗口中选择可用的调试按钮。服务器启动后,IDE 将自动连接以允许调试您部署的应用程序。