`
xnk9499
  • 浏览: 38297 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

【转】Remote debugging of Tomcat using Eclipse

    博客分类:
  • JAVA
 
阅读更多

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:

  1. Run the application indicating to the JVM that it has to be executed in debug mode.
  2. The source code of the application we want to debug.
  3. 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.

Debug configuration

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).

New debug configuration

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
Debug configuration sample data

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/

分享到:
评论

相关推荐

    Visual Studio 2005 Remote Debugging.mht

    Visual Studio 2005 Remote Debugging.mht

    eclipse远程调试tomcat

    - 输入配置名称,例如`Remote Debugging Tomcat`。 - 在`Connect`选项卡中,设置`Host`为你运行Tomcat服务器的主机地址,`Port`设置为之前配置的8000。 2. **设置断点**: - 在Eclipse中打开你想调试的Java类,...

    liferay tomcat eclipse debug

    标题 "liferay tomcat eclipse debug" 暗示了我们正在讨论如何在Eclipse环境中调试Liferay Portal,这是一个基于Java的开源企业级内容管理和协作平台,通常与Apache Tomcat这样的Servlet容器结合使用。以下是关于这...

    Debugging Pentaho 2.0 with Eclipse

    ### 使用Eclipse构建与调试Pentaho 2.0 #### 概述 本文档将详细介绍如何在Eclipse集成开发环境中设置开发环境,包括如何连接到Pentaho Subversion仓库、检出Pentaho项目、构建这些项目以及使用独立的Java应用...

    MyEclipse_Remote_Debugging_Quickstart

    通过本教程,您将学会如何配置服务器以支持远程调试、部署应用程序到服务器、使用自定义的 Eclipse 启动配置与服务器通信以及在所有服务器中调试 Java 代码和在 JSR-045 兼容服务器中调试 JSP。 #### 前言 本文档...

    The Art of Debugging with GDB, DDD, and Eclipse

    ### 《调试的艺术:使用GDB、DDD及Eclipse》 #### 书籍概述 《调试的艺术:使用GDB、DDD及Eclipse》是一本由Norman Matloff与Peter Jay Salzman合著的专业书籍,旨在帮助程序员掌握高效调试技巧。本书不仅深入介绍...

    The.Art.of.Debugging.with.GDB.DDD.and.Eclipse.pdf

    然而,根据标题和描述,我们可以推断出这本书的内容涵盖使用GDB、DDD和Eclipse进行程序开发调试的方法。GDB(GNU Debugger)是一个由GNU开源组织提供的强大的命令行调试工具,DDD(Data Display Debugger)是基于GDB...

    THE ART OF DEBUGGING with GDB, DDD, and Eclipse

    ### 调试的艺术:利用GDB、DDD和Eclipse #### 一、书籍简介 《调试的艺术》是由诺曼·马特洛夫(Norman Matloff)和彼得·杰伊·萨尔兹曼(Peter Jay Salzman)共同编著的一本专业书籍。该书由No Starch Press出版,并...

    Developing and Debugging CICS Programs Using Rational Developer for System z(RDz).pdf

    RDz是一款基于Eclipse的集成开发环境(IDE),旨在提供一个一站式的平台用于CICS应用程序的编码和部署。该工具支持多种编程语言,包括但不限于COBOL、PL/I、C、C++、汇编语言和Java。通过RDz,开发者可以在一个环境中...

    the art of debugging

    the art of debugging

    Manning - Eclipse In Action.pdf

    "Manning - Eclipse in Action.pdf" is a comprehensive guide that covers both the practical aspects of using Eclipse as well as the advanced topics of extending its functionality. Whether you are a ...

    eclipse远程debug

    eclipse 远程 debug 是一种常用的 debugging 技术,用于在远程服务器上调试 Web 应用程序。今天我们将讨论如何使用 eclipse 远程 debug tomcat 和 websphere 的 web 应用。 首先,让我们了解一下 JPDA 的概念。JPDA...

    Tomcat The Definitive Guide, 2nd Edition(PDF)

    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 ...

    Java.EE.Development.with.Eclipse.2nd.Edition.178528534

    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 ...

    Art of Debugging with GDB, DDD, and Eclipse 软件调试的艺术

    《软件调试的艺术》一书,无论是中文版还是英文版,都是深入探讨调试技术的重要资源,尤其对于使用GDB、DDD和Eclipse等工具的开发者来说,更是不可或缺的参考书籍。调试是软件开发过程中的关键环节,它能帮助我们找...

    Advanced.Apple.Debugging.&.Reverse.Engineering.v2.0 Code Part2

    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 ...

    jd-eclipse-site-1.0.0-RC2.zip、jd-eclipse-2.0.0.zip

    It allows you to display all the Java sources during your debugging process, even if you do not have them all. Installation Download JD-Eclipse ZIP file, Launch Eclipse, Click on "Help > Install New ...

    Agile.Java.Development.with.Spring.Hibernate.and.Eclipse

    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 Code part1

    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 ...

Global site tag (gtag.js) - Google Analytics