This post shows how to debug an application deployed in Apache Tomcat remotely (Tomcat is a popular Servlet container). This is valid for any other application server or any other Java application since the debug in remote is a feature of the JVM (Java Virtual Machine) over which any Java application is run.
For debugging a Java application remotely with Eclipse we need three things:
- Run the application indicating to the JVM that it has to be executed in debug mode.
- The source code of the application we want to debug.
- Configure Eclipse to debug the application.
Starting Apache Tomcat in debug mode
First of all we have to restart the Tomcat with debug option for this purpose we need to pass to JVM (Java Virtual Machine) the options
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
JVM opens a port in current machine allowing external applications (like Eclipse) to connect for debugging purposes.
To do that with Tomcat we have to set the environment variable JAVA_OPTS that is read by Tomcat in startup.sh file.
1) Set variable and make it available. we can choose the port number, in this example is used 8000 number.
1
|
export JAVA_OPTS= "-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
|
2) Start Tomcat (from bin folder):
1
|
. /startup .sh
|
Configuring Eclipse to remote debugging
First of all, we have to open or import the project with the source code of the application we want to debug. Afterward we have to setup the debug from Eclipse:
1) Clicking on the right side (arrow facing to above) of the “Debug” button (the button with the bug) that is in the toolbar and the clicking on “Debug configurations…” or in the menu Run > Debug configurations… Then a new window with the different debug configuration will be opened.
2) Select “Remote Java Application” in the left menu and then press on “New launch configuration” button (the button with the folder icon in the top-left corner).
3) Fill the configuration with the data corresponding with our Tomcat instance:
- Project: The project we want to debug: it has to contain the source code for the application we want to debug.
- Connection Type: Standard (Socket Attach).
- Host: IP of the server in which is Tomcat installed.
- Port: Port indicated to JVM in address parameter. Port 8000 in our example
Remote Debugging of Tomcat with Eclipse
4) Execute the debug. We have to click on the button “Debug” and Eclipse will connect with Tomcat (it had to be previously running as I mentioned in this post). Now we have to put the breakpoints inside the Eclipse project to debug as we do with a regular project running in a local Tomcat.
And that’s all, if everything works well you can debug your Tomcat remotely. Now there is a long work to do debugging your app. Good luck!
from:http://davidsblog.eu/remote-debugging-of-tomcat-using-eclipse/
相关推荐
Debugging Pentaho 2.0 with Eclipse
Visual Studio 2005 Remote Debugging.mht
MyEclipse_Remote_Debugging_Quickstart.pdf Outline 1. Preface 2. Introduction 3. Configuring the Server for Remote Debugging 1. WebLogic 8.1 Server 2. Tomcat 5.x Server 3. Sun Java System ...
Developing and Debugging CICS Programs Using Rational Developer for System z(RDz)
ollydbg Debugging of DLLs
The Art of Debugging illustrates the use of three of the most popular debugging tools on Linux/Unix platforms: GDB, DDD, and Eclipse. In addition to offering specific advice for debugging with each ...
Remote Debugging Summary 8. Leveraging the Windows 2000 Event Log The Windows 2000 Event Log Defined Web Applications Can Use the Event Log The System.Diagnostics Event Log Interface ...
Debugging using DWARF.pdf
Through a combination of best ...Dissect software behavior on Windows using tracing and debugging tools * Apply the above strategies to enhance knowledge of a few key fundamental topics in Windows
英文原版。是关于使用GDB,DDD,Eclipse进行调试的优秀工具书,比manual要好多了。
the art of debugging
Amazon五星图书,优秀的软件调试入门著作 总结业界多年口口相传的调试经验 丰富的C/C++实例阐述适用于各种平台与编程语言的通用调试原则 详解GDB、DDD和Eclipse三大工具应用
Debugging and Troubleshooting-diagnosing problems with Tomcat or a web application * * Compiling your own Tomcat, rather than using the pre-built release * * Running two or more Tomcat ...
讲述如何使用GDB进行程序开发调试,详述了GDB的各种用法和命令
A Debugging Tool for Application using Multiple DLLs使用多个dll的调试工具
This guide provides a complete overview of developing JEE applications using Eclipse. The many features of the Eclipse IDE are explained. These enable the rapid development, debugging, testing, and ...
Every software developer and IT professional understands the crucial importance of effective debugging. Often, debugging consumes most of a developer’s workday, and mastering the required techniques ...
Advanced Apple Debugging & Reverse Engineering, Second Edition ISBN: Learn the powerful secrets of Apple’s software debugger, LLDB, that can get more information out of any program than you ever ...
Agile Java™ Development With Spring, Hibernate and Eclipse is a book about robust technologies and effective methods which help bring simplicity back into the world of enterprise Java development....
Advanced Apple Debugging & Reverse Engineering, Second Edition ISBN: Learn the powerful secrets of Apple’s software debugger, LLDB, that can get more information out of any program than you ever ...