`

remote debugging

阅读更多
http://www.eclipsezone.com/eclipse/forums/t53459.html

Remote Debugging with Eclipse

At 8:22 PM on Nov 1, 2005, Levent Gurses Javalobby Newcomers wrote:

<!-- Synopsis -->

How many times trying to fix a server-side Java problem appeared trivial, but getting to the source of the problem took all the time? A remote debugger attached to a Java application can shorten the defect-discovery times significantly and make the process more enjoyable.

<!-- What is it -->

The Java Debugger

The Java Debugger (jdb) is a dynamic, controlled, assignment-based debugging tool. It helps find and fix bugs in the Java language programs both locally and on the server. To use jdb in a J2EE application server you must first launch it with debugging enabled and attach to the server from the debugger through a JPDA port (Default port is 1044).

The default JPDA options for J2EE servers are as follows:

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

The jdb parameters specify the way debugger will operate. For instance transport=dt_socket instructs the JVM that the debugger connections will be made through a socket while the address=1044 parameter informs it that the port number will be 1044. Similarly, if you substitute suspend=y , the JVM starts in suspended mode and stays suspended until a debugger is attached to it. This may be helpful if you want to start debugging as soon as the JVM starts.

 


Debugging WebLogic

Debugging WebLogic is no different than debugging any other Java remote application. You need to make sure to launch it with the required debugging arguments and attach a debugger. In the case of WebLogic 8.1, you need to add these arguments to the startup script. WebLogic comes with several launch scripts (*.sh and *.cmd) under BEA_HOME/weblogic81/server/bin.

  1. Locate startWSL.cmd and add the following variable DEBUG_OPTS:
    set DEBUG_OPTS = -Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n
        
  2. Next, insert the new variable to the WebLogic startup command, after "%JAVA_HOME%\bin\java" and preferably before the other options.
  3. Your startup script should look like:

    "%JAVA_HOME%\bin\java" %DEBUG_OPTS% %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS%-Dweblogic.Name=%SERVER_NAME% -Dweblogic.management.username= %WLS_USER%-Dweblogic.management.password= %WLS_PW% -Dweblogic.management.server= %ADMIN_URL%-Dweblogic.ProductionModeEnabled= %PRODUCTION_MODE%-Djava.security.policy= "%WL_HOME%\server\lib\weblogic.policy" weblogic.Server


Debugging JBoss

Same as WebLogic, except that you need to change run.bat/run.sh located under JBOSS_HOME/bin.

Linux users should see something similar to this:

 $ cd /var/jboss4/bin
$ sh ./run.sh
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /var/jboss4
JAVA: /usr/java/j2sdk1.4.2_06/bin/java
JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh
DEBUG_OPTS = -Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n
CLASSPATH: /var/jboss4/bin/run.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar
=========================================================================

Debugging Tomcat

Again, very much similar to WebLogic and JBoss, except that you need to change catalina.bat/catalina.sh located under TOMCAT_HOME/bin.


Debugger Verification

Now you can launch your application in debug mode. Just to make sure that the server is listening to port 1044 you can run netstat /a. You should see port 1044 in the list of open ports (See Figure 1: List of open ports: netstat -a).

Figure 1 List of open ports: netstat -a

 


The Eclipse Connection

After making sure WebLogic is listening for incoming connections on port 1044, what is left is to tell Eclipse to connect to this port and you are ready to debug.

  1. In Eclipse, navigate to Run | Debug (See Figure 2: Create new Remote Java Application configuration in Eclipse ).
  2. Select Remote Java Application , on the left column. Click New , on the bottom of the same column.
  3. In the Create configuration screen you'll be prompted to enter some values. Start with a meaningful name. In my case that's WebLogic Instance . For Project, select the Java project that contains the source code you want to debug. Leave Connection Type in default, i.e. Standard (Socket Attach) . For Host , enter localhost. If you want to debug a remote server, enter its hostname or IP address. For port, enter 1044 or the port you defined in your WebLogic startup script.
  4. Click Apply
  5. Make sure WebLogic instance is running in debug mode. In the same screen click Debug . Eclipse should automatically take you to the Debug perspective and you should see a stack trace in the Debug view.
  6. If you are not automatically taken to the Debug perspective, select Window | Open Perspective | Other and then click Debug.

Figure 2 Create new Remote Java Application configuration in Eclipse


Figure 3 Breakpoint hit in Eclipse debugger

<span http://

Eclipse Debug window should automatically pop-up with the stack pointer on your first breakpoint (See Figure 3: Breakpoint hit in Eclipse's debugger ). After that, you can use all the various functions that the debugger has to offer, namely variable assignments, step-into, drop to frame, etc.

 


References


System Information

  • Windows 2000
  • JDK 1.4.2_03
  • Eclipse 3.0
  • BEA WebLogic 8.1
  • JBoss 4.0.2
  • Tomcat 5.0.26

About the Author

Levent Gurses is a Washington, DC-based technology consultant. He is also one of the co-founders of Jacoozi , an integrated solutions provider based in Alexandria, VA. In his professional life Levent helps clients overcome their J2EE challenges and develop leaner and meaner software development practices. Most of his free time goes in reading and motorcycle racing.

  Click to reply to this thread Reply
1. At 4:57 PM on Nov 3, 2005, the Q Master Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

The major problem to me is not how to set the remote debugger in eclipse but rather to transform the development + debugging a easy proccess.

I managed to debug and edit my J2EE project in the same time with tomcat using Eclipse and I'm looking to find a similar way with Weblogic.

I don't like the fact that I loose time to deploy every single time before debugging and I aim to have the Weblogic looking in my eclipse project (that is structured as a exploded war).

One tomcat advantange - it has an option to load the changes on the fly and that shortens the development and debugging process.
Affordable Stock Photography http://www.goodstockimages.com
  Click to reply to this thread Reply
2. At 5:09 PM on Nov 3, 2005, Levent Gurses Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

Hot code replace (hot deploys) is a time-saving feature, I agree and Tomcat is by far the easiest to set for hot code replace. JBoss can also be tuned to support it, though not for all class changes. Interestingly, I had hard time achieving the same with WebLogic. Maybe BEA gurus can help us here?

PS: You may want to have a look at this discussion (http://jroller.com/page/gursesl/cleanfulltext/remote_application_debugging_with_weblogic)
Levent Gurses
Jacoozi - New Generation E-Solutions for >> Thinking Companies
www.jacoozi.com
  Click to reply to this thread Reply
3. At 7:36 AM on Nov 4, 2005, Michele Campeotto Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

For Tomcat (5.5 here, don't know about other versions) you don't need to edit catalina.sh, just start it with:

$ ./bin/catalina.sh jpda start

and it will use dt_socket on port 8000.

(I had to do this yesterday :) )
  Click to reply to this thread Reply
4. At 3:29 PM on Nov 11, 2005, Sunil Kamath Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

Here's another good article on ths subject:
http://www-128.ibm.com/developerworks/library/os-ecdiag/?ca=dnt-427
  Click to reply to this thread Reply
5. At 3:39 PM on Nov 11, 2005, Levent Gurses Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

I like the fact that you can debug an Eclipse workbench remotely:

> Listing 1. Launching a remotely debuggable workbench

>eclipse.exe -vmargs -Xdebug -Xnoagent \
>-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n


Levent Gurses
Jacoozi - New Generation E-Solutions for >> Thinking Companies
www.jacoozi.com
  Click to reply to this thread Reply
6. At 9:12 AM on Dec 19, 2005, Michael Murphy Javalobby Newcomers wrote:

WebSphere - Enabling debugging

From the WebSphere 5.X/6.X console, go to

Servers > Application Servers > [SERVERNAME] > Process Definition > Java Virtual Machine

Check off Debug Mode
Arguments can be edited in the field called "Debug arguments".
  Click to reply to this thread Reply
7. At 12:19 PM on Jan 6, 2006, David Peng Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

Do you have experience for remote debugging Tomcat 5.5 on windows platform, there is no such batch file, like tomcat.bat, startup.bat, shutdown.bat.
Thanks.
  Click to reply to this thread Reply
8. At 9:03 AM on Jun 9, 2006, Sunil Kamath Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

More on this at: http://www-128.ibm.com/developerworks/library/os-ecdiag/?ca=dnt-427
  Click to reply to this thread Reply
9. At 10:04 AM on Sep 25, 2006, Levent Gurses Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

Here is an updated version of the write-up covering several more app servers:


Remote Debugging with Eclipse (Jacoozi Article)
Levent Gurses
Jacoozi - New Generation E-Solutions for >> Thinking Companies
www.jacoozi.com
  Click to reply to this thread Reply
10. At 10:18 AM on Apr 24, 2007, sumedh Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

I tried this with Weblogic but its not working. It straight away starts as usual in running mode on 7001 port.

Attached the screenshot.

Marked in red are the debug options added to java start command.
  Click to reply to this thread Reply
11. At 11:10 AM on Jun 12, 2007, dushyant Javalobby Newcomers wrote:

Re: Remote Debugging with Eclipse

Hi,

I am remote debugging Weblogic 8.1 but everytime I make even a smallest of code change the hot code replace always fails. The weblogic is using the JRE jrockit81sp5_142_08 so I have configured eclipse also to use the same JRE but code swap always fails. Please help.
  Click to reply to this thread Reply
13. At 5:36 PM on Jul 18, 2007, Alex Blewitt DeveloperZone Top 100 wrote:

Re: Remote Debugging with Eclipse

Not all JREs support hot-swap bytecode; JRockit is one of them. In short; you can't do it if you're using JRockit. (In Eclipse 3.3, if you right-click on a remote application, then you can see what services the remote VM provides.)

Alex.
分享到:
评论

相关推荐

    Visual Studio 2005 Remote Debugging.mht

    Visual Studio 2005 Remote Debugging.mht

    Visual Studio Remote Debug

    Visual Studio Remote Debugging 是一种强大的工具,允许开发者在一台计算机(本地机)上使用Visual Studio进行代码编写,而实际的程序执行和调试则在另一台计算机(远程机)上进行。这种方式尤其适用于处理大型项目...

    Remote Debugging Information Server-开源

    远程调试信息服务器是一种开源软件,它为开发者提供了一个强大的工具,可以进行远程的日志记录调试,并通过Web界面方便地查看和分析这些信息。这个系统的核心功能是帮助开发人员在远离实际运行环境的情况下诊断和...

    PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2)

    PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2) PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2) PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2) PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2)

    Debugging-with-GDB-带书签

    "Targets"和"Remote Debugging"分别说明了指定调试目标和远程调试的技巧,这在跨平台或网络环境下的开发中十分关键。最后,"Configurations"可能涉及GDB的配置选项和自定义,以适应不同用户的需求和工作流。 总之,...

    ASP.NET MVC with Entity Framework and CSS [2016]

    • Azure deployment using Code First Migrations, remote debugging and viewing/editing your remote data • CSS Styling including animation and media queries What You Will Learn: • Get up and running...

    Debugging with GDB --2003年6.0

    Debugging programs with multiple processes . . . . . . . . . . . . 23 24 25 25 26 26 27 28 28 30 Stopping and Continuing . . . . . . . . . . . . . . . . . . 33 5.1 Breakpoints, watchpoints, and ...

    chrome-edge-launcher:从节点轻松启动Microsoft Edge

    ,自动化方案增加噪音在可用端口上打开浏览器的remote-debugging-port端口自动找到要启动的Edge二进制文件每次启动使用新的Edge配置文件,并使用kill()清理自身绑定Ctrl-C (默认情况下)以终止Edge进程公开了一小...

    MyEclipse_Remote_Debugging_Quickstart

    ### MyEclipse 远程调试快速入门 #### 摘要 本文档旨在介绍如何使用 MyEclipse 进行远程调试。它适用于那些不在运行 MyEclipse 的机器上启动的应用服务器,或者在不同机器上的应用服务器。通过本教程,您将学会如何...

    Debugging with GDB --2001年5.3

    Debugging programs with multiple processes . . . . . . . . . . . . 23 24 25 25 26 26 27 28 28 30 Stopping and Continuing . . . . . . . . . . . . . . . . . . 33 5.1 Breakpoints, watchpoints, and ...

    Addison Wesley - Embedded Linux - Hardware,Software,and Interfacing.chm

    It includes a comprehensive discussion of platform selection, crosscompilation, kernel compilation, root filesystem creation, booting, remote debugging, real-world interfacing, application control, ...

    vc远程系统

    - 安装并启动Remote Debugging Monitor,通常可以在“C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Remote Debugger”路径下找到。 - 确保防火墙设置允许msvsmon.exe的入站连接,...

    wince远程调试工具

    1. **调试器**:如Microsoft Visual Studio或Platform Builder中的Remote Debugging Monitor(RDM),它们在开发者的工作站上运行,接收并解析来自远程设备的调试信息。 2. **连接方式**:调试通信可以是通过串口、...

Global site tag (gtag.js) - Google Analytics