- 浏览: 21763 次
文章分类
最新评论
remote debugging
Remote Debugging with Eclipse
At 8:22 PM on Nov 1, 2005, Levent Gurses wrote:
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.
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.
- Locate startWSL.cmd and add the following variable DEBUG_OPTS:
set DEBUG_OPTS = -Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n
- Next, insert the new variable to the WebLogic startup command, after "%JAVA_HOME%\bin\java" and preferably before the other options.
- 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.
- In Eclipse, navigate to Run | Debug (See Figure 2: Create new Remote Java Application configuration in Eclipse ).
- Select Remote Java Application , on the left column. Click New , on the bottom of the same column.
- 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.
- Click Apply
- 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.
- 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
- Debugging J2EE Applications
- Connecting to a Remote VM with the Java Remote Application Launcher
- Debugging with the Eclipse Platform
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.
12 replies so far ( Post your own)
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.
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)
Jacoozi - New Generation E-Solutions for >> Thinking Companies
www.jacoozi.com
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 )
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
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
Jacoozi - New Generation E-Solutions for >> Thinking Companies
www.jacoozi.com
WebSphere - Enabling debugging
From the WebSphere 5.X/6.X console, go toServers > Application Servers > [SERVERNAME] > Process Definition > Java Virtual Machine
Check off Debug Mode
Arguments can be edited in the field called "Debug arguments".
- WSJavaDebug.JPG (9.7 K)
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.
Re: Remote Debugging with Eclipse
More on this at: http://www-128.ibm.com/developerworks/library/os-ecdiag/?ca=dnt-427Re: Remote Debugging with Eclipse
Here is an updated version of the write-up covering several more app servers:Remote Debugging with Eclipse (Jacoozi Article)
Jacoozi - New Generation E-Solutions for >> Thinking Companies
www.jacoozi.com
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.
- remote_debug.jpg (146.0 K)
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.
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
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 ...
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 ...
调试服务器允许远程调试日志记录并通过基于Web的界面访问信息。
r Remote debugging s The GDB remote serial protocol s What the stub can do for you s What you must do for the stub s Putting it all together s Communication protocol s Using the gdbserver program s ...
PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2) PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2) PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2) PHP调试,使用Komodo和Xdebug进行PHP程序的调试(2)
• 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 ...
• GDB for remote debugging QEMU • Generation of guest software application using Xilinx® PetaLinux and SDK tools • Device trees This document provides the basic information to familiarize, use,...
• 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 programs with multiple processes . . . . . . . . . . . . 23 24 25 25 26 26 27 28 28 30 Stopping and Continuing . . . . . . . . . . . . . . . . . . 33 5.1 Breakpoints, watchpoints, and ...
,自动化方案增加噪音在可用端口上打开浏览器的remote-debugging-port端口自动找到要启动的Edge二进制文件每次启动使用新的Edge配置文件,并使用kill()清理自身绑定Ctrl-C (默认情况下)以终止Edge进程公开了一小...
Debugging programs with multiple processes . . . . . . . . . . . . 23 24 25 25 26 26 27 28 28 30 Stopping and Continuing . . . . . . . . . . . . . . . . . . 33 5.1 Breakpoints, watchpoints, and ...
It includes a comprehensive discussion of platform selection, crosscompilation, kernel compilation, root filesystem creation, booting, remote debugging, real-world interfacing, application control, ...
To run a single integration test in debug mode (for remote debugging in an IDE) on the default port of 5005: $ mvn verify -DrunITs -Dit.test=<<YourIT>> -Dmaven.failsafe.debug To skip test $ ...
Learn how to spread around your debugging using different connection types that make up remote debugging. This article explains the features and examples that show how to set up remote application ...
- Chrome Remote Debugging: Debug your code in Chrome, from Komodo! No more context switching or locating the same code you've been working on again in the Chrome dev tools. You can write code, place...
Remote Debugging Tuning a Job Profiling Tasks MapReduce Workflows Decomposing a Problem into MapReduce Jobs JobControl Apache Oozie 6. How MapReduce Works . . . . . . . . . . . . . . . . . . . . . . ...