Today I tried to use remote debugging with Eclipse and Tomcat.
I usually use a Tomcat Sysdeo Plugin to run Tomcat inside Eclipse, but today I faced remote debugging.
To run tomcat in remote debugging you can start it with command
catalina jpda start
But this will start remote debugging using shared memory, and Eclipse, as far as I know, does not support shared memory as transport for deubugging.
The alternative is to use a socket as transport for JPDA.
You simply set some enviroment variable that will be checked by catalina startup script, as in following example:
set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
... then you can run ...
D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda run
...or...
D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda start
This tells catalina script to use socket transport for debugging and to listen on port 5050. If you don't specify the port, it will be assigned randomly.
When you start tomcat, you'll see some messages on console saying that debugging socket is listening:
D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda run
Using CATALINA_BASE: D:\Java\jakarta-tomcat-5.5.7
Using CATALINA_HOME: D:\Java\jakarta-tomcat-5.5.7
Using CATALINA_TMPDIR: D:\Java\jakarta-tomcat-5.5.7\temp
Using JAVA_HOME: d:\Java\jdk1.5.0_04
Listening for transport dt_socket at address: 5050
4-ott-2005 18.26.11 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
4-ott-2005 18.26.11 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1162 ms
4-ott-2005 18.26.11 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
4-ott-2005 18.26.11 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
4-ott-2005 18.26.11 org.apache.catalina.core.StandardHost start
Now it's time to connect to that socket using Eclipse: see following picture.
On "Connection Properties" you can configure a remote VM that you want to debug. Then place your breakpoints and run the shown launch configuration.
Shared memory is easier to be used: with tomcat you don't have to set up environment variables, and for IDE supporting it (I used this with IntelliJ), you only need to specify the name of the shared space. This won't work if the VM to debug is on a remote computer but can be helpful anyway. I tried to find shared memory support in Eclipse but I didn' find it, and I believe it doesn't have.
Remote debugging is more useful when you have to attach to a running instance on a remote server on which the bug is alive. Shared memory support lack is not that problem.
One thing that you cannot do running programs inside Eclipse under Windows is to get a Thread dump. On Windows you can get a Thread Dump pressing CTRL+Break in the DOS console, but this doesn't work on Eclipse console. On Linux you can use "kill -3", and I think this work even running processes in Eclipse. Maybe it's possible also in Windows, using some esotic tool, but I don' know... also I don't know if Windows supports several kill signals.
分享到:
相关推荐
To set a JDK as default JRE for Eclipse open the preference window : Window -> Preferences -> Java -> Installed JREs. This JRE must be a JDK (This is a Tomcat prerequisite). The plugin sets itself ...
在Eclipse中,你可以在"Servers"视图中右键点击服务器,选择"Open",然后在打开的"Server Location"中选择"Use Tomcat installation",这样Eclipse会直接使用Tomcat的原始配置文件。 以上就是Eclipse与Tomcat连接的...
Tomcat: The Definitive Guide is a valuable reference for administrators and webmasters, a useful guide for programmers who want to use Tomcat as their web application server during development or in ...
Eclipse 是一个功能强大且广泛使用的集成开发环境(IDE),在 Web 开发中需要配置 Tomcat Server 来进行 Debug 和测试。下面将详细介绍 Eclipse 中配置 Tomcat Server 的方法。 一、配置 Server Runtime ...
Through the course of the book, you’ll learn how to use OpenShift and the Wildfly application server to build and then immediately deploy a Java application online. Learn about OpenShift’s core ...
在Eclipse的运行菜单中,选择"Run Configurations",创建一个新的"Java Application"配置。在"Main Class"字段中输入你要调试的类名,然后在"Arguments"选项卡中设置任何必要的命令行参数。 在运行配置中,确保...
you will need some knowledge of the concepts of Android application development., What You Will Learn, Build new Android apps and libraries using Android Studio and Gradle, Migrate projects from ...
Author Jonathan Zdziarski, the developer of the first fully functional application using the open iPhone toolkit, now explains in clear language how to create applications using Objective-C and the ...
### 使用Eclipse进行C/C++程序调试 #### 概述 Eclipse 是一款非常流行的开源集成开发环境(IDE),广泛应用于各种编程语言的开发中,包括C和C++。通过Eclipse,开发者不仅可以编写代码,还可以编译、运行以及调试...
In this fast-paced book on the Docker open standards platform for developing, packaging and running portable distributed applications, Deepak Vorhadiscusses how to build, ship and run applications on ...
UltraEdit and UEStudio provide multiple methods to quickly open files without using the standard Open File dialog. A favorite method among power users is the Quick Open in the File menu. The benefit ...
Know where and how much to apply instrumentation to your application code Identify metrics with labels using unique key-value pairs Get an introduction to Grafana, a popular tool for building ...
Eclipse Tomcat插件是开发Java Web应用的重要辅助工具,它允许开发者在Eclipse集成开发环境中直接管理和运行Tomcat服务器,极大地提高了开发效率。本文将详细介绍这个插件的使用、功能以及与源码和工具相关的知识。 ...
### 如何在Eclipse平台上调试C与C++程序 #### 前言 本文旨在介绍如何在Eclipse集成开发环境中调试C与C++程序。为了更好地理解本文内容,读者需具备基本的Eclipse安装和使用知识,以及撰写C/C++程序的基础能力。...
eclipse vi plugin 1.16 Here the ChangeLog: - 0000403: [editor_integration] would be nice to be able to use ctrl-v to ...- 0000570: [vim_compatibility] Choose delimiter for search and replace function
- **The Tomcat Servlet Container**: Tomcat is a popular open-source servlet container used for deploying web applications. It supports the latest versions of the Java Servlet, JavaServer Pages (JSP), ...
- 在"Server Locations"部分,你可以选择"Use workspace metadata (does not modify Tomcat installation)",这样Eclipse会在工作空间中管理服务器配置,而不会改动Tomcat的原始配置文件。 - 点击"Finish",新的...
This book is for those Web developers and/or Java programmers new to the open-source Apache Tomcat Web server. It's also for those new to the latest release, version 7. 作者简介: Aleksa Vukotic is ...