---
title: "remote debugging"
author: "guanshuiwang"
date: "2010-09-02T14:43:00Z"
tags: []
slug: "remote-debugging"
draft: false
lastmod: "2012-09-21T16:22:23Z"
id: 1683115
url: "https://guanshuiwang.iteye.com/blog/1683115"
---

http://www.eclipsezone.com/eclipse/forums/t53459.html

# Remote Debugging with Eclipse

#### At 8:22 PM on Nov 1, 2005, [Levent Gurses](http://www.eclipsezone.com/forums/profile.jspa?userID=185068) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "Javalobby Newcomers") wrote:

![](http://www.eclipsezone.com/forums/avatar-display.jspa?avatarID=11&file=av.png)

&lt;!-- Synopsis --&gt;

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.

Table of Contents

- [The Java Debugger](http://www.eclipsezone.com/eclipse/forums/t53459.html#jdebugger)
- [Debugging WebLogic](http://www.eclipsezone.com/eclipse/forums/t53459.html#weblogic)
- [Debugging JBoss](http://www.eclipsezone.com/eclipse/forums/t53459.html#jboss)
- [Debugging Tomcat](http://www.eclipsezone.com/eclipse/forums/t53459.html#tomcat)
- [Debugger Verification](http://www.eclipsezone.com/eclipse/forums/t53459.html#verify)
- [The Eclipse Connection](http://www.eclipsezone.com/eclipse/forums/t53459.html#eclipse)
- [References](http://www.eclipsezone.com/eclipse/forums/t53459.html#references)
- [System Info](http://www.eclipsezone.com/eclipse/forums/t53459.html#systeminfo)
- [About the Author](http://www.eclipsezone.com/eclipse/forums/t53459.html#about)

&lt;!-- What is it --&gt;

[]()

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

![](http://www.jacoozi.com/uploadfiles/blog/debug_image002.png)

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

![](http://www.jacoozi.com/uploadfiles/blog/debug_image004.png)

**Figure 2 Create new Remote Java Application configuration in Eclipse**

**![](http://www.jacoozi.com/uploadfiles/blog/debug_image008.png)**

**Figure 3 Breakpoint hit in Eclipse debugger**

&lt;span [http://](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](http://java.sun.com/j2ee/1.4/docs/devguide/dgdebug.html)
- [Connecting to a Remote VM with the Java Remote Application Launcher](http://help.eclipse.org/help31/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-141.htm)
- [Debugging with the Eclipse Platform](http://www-106.ibm.com/developerworks/opensource/library/os-ecbug)

[]()

# 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

![](http://www.jacoozi.com/images/stories/levent_portrait.jpg)

Levent Gurses is a Washington, DC-based technology consultant. He is also one of the co-founders of [Jacoozi](http://www.jacoozi.com) , 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.

&lt;!-- BEGIN ADVERTPRO ADVANCED CODE BLOCK --&gt;[![Click Here!](http://avpa.javalobby.org/servlet/view/banner/image/zone?zid=72&pid=0&position=1)](http://avpa.javalobby.org/servlet/click/zone?zid=72&pid=0&lookup=true&position=1)&lt;!-- END ADVERTPRO ADVANCED CODE BLOCK --&gt;

### 12 replies so far ([![](http://www.eclipsezone.com/images/std/icons/write_16x16.gif "Reply to this Thread")](http://www.eclipsezone.com/forums/post%21reply.jspa?threadID=53459) [Post your own](http://www.eclipsezone.com/forums/post%21reply.jspa?threadID=53459))

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91951776 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91951776 "Click to reply to this thread")

[1.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91951776 "Permlink to this reply") At 4:57 PM on Nov 3, 2005, [the Q Master](http://www.eclipsezone.com/forums/profile.jspa?userID=187917) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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](http://www.goodstockimages.com)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91951777 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91951777 "Click to reply to this thread")

[2.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91951777 "Permlink to this reply") At 5:09 PM on Nov 3, 2005, [Levent Gurses](http://www.eclipsezone.com/forums/profile.jspa?userID=185068) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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](http://jroller.com/page/gursesl/cleanfulltext/remote_application_debugging_with_weblogic))

Levent Gurses  
Jacoozi - New Generation E-Solutions for &gt;&gt; Thinking Companies  
[www.jacoozi.com](http://www.jacoozi.com)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91951945 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91951945 "Click to reply to this thread")

[3.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91951945 "Permlink to this reply") At 7:36 AM on Nov 4, 2005, [Michele Campeotto](http://www.eclipsezone.com/forums/profile.jspa?userID=187942) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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 ![:)](http://www.eclipsezone.com/eclipse/forums/images/emoticons/happy.gif) )

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91953535 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91953535 "Click to reply to this thread")

[4.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91953535 "Permlink to this reply") At 3:29 PM on Nov 11, 2005, [Sunil Kamath](http://www.eclipsezone.com/forums/profile.jspa?userID=188329) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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](http://www-128.ibm.com/developerworks/library/os-ecdiag/?ca=dnt-427)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91953542 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91953542 "Click to reply to this thread")

[5.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91953542 "Permlink to this reply") At 3:39 PM on Nov 11, 2005, [Levent Gurses](http://www.eclipsezone.com/forums/profile.jspa?userID=185068) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "Javalobby Newcomers") wrote:

### Re: Remote Debugging with Eclipse

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

&gt; **Listing 1. Launching a remotely debuggable workbench**

&gt;eclipse.exe -vmargs -Xdebug -Xnoagent \\  
&gt;-Xrunjdwp:transport=dt\_socket,address=8000,server=y,suspend=n

Levent Gurses  
Jacoozi - New Generation E-Solutions for &gt;&gt; Thinking Companies  
[www.jacoozi.com](http://www.jacoozi.com)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91975204 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91975204 "Click to reply to this thread")

[6.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91975204 "Permlink to this reply") At 9:12 AM on Dec 19, 2005, [Michael Murphy](http://www.eclipsezone.com/forums/profile.jspa?userID=189875) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "Javalobby Newcomers") wrote:

### WebSphere - Enabling debugging

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

Servers &gt; Application Servers &gt; \[SERVERNAME] &gt; Process Definition &gt; Java Virtual Machine

Check off Debug Mode  
Arguments can be edited in the field called "Debug arguments".

- [![Attachment](http://www.eclipsezone.com/servlet/JiveServlet?attachImage=true&contentType=image%2Fjpeg&attachment=3589)](http://www.eclipsezone.com/servlet/JiveServlet/download/18111-53459-91975204-3589/WSJavaDebug.JPG) [WSJavaDebug.JPG](http://www.eclipsezone.com/servlet/JiveServlet/download/18111-53459-91975204-3589/WSJavaDebug.JPG) (9.7 K)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91979702 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=91979702 "Click to reply to this thread")

[7.](http://www.eclipsezone.com/eclipse/forums/t53459.html#91979702 "Permlink to this reply") At 12:19 PM on Jan 6, 2006, [David Peng](http://www.eclipsezone.com/forums/profile.jspa?userID=190610) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92025038 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92025038 "Click to reply to this thread")

[8.](http://www.eclipsezone.com/eclipse/forums/t53459.html#92025038 "Permlink to this reply") At 9:03 AM on Jun 9, 2006, [Sunil Kamath](http://www.eclipsezone.com/forums/profile.jspa?userID=188329) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "Javalobby Newcomers") wrote:

### Re: Remote Debugging with Eclipse

More on this at: [http://www-128.ibm.com/developerworks/library/os-ecdiag/?ca=dnt-427](http://www-128.ibm.com/developerworks/library/os-ecdiag/?ca=dnt-427)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92041039 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92041039 "Click to reply to this thread")

[9.](http://www.eclipsezone.com/eclipse/forums/t53459.html#92041039 "Permlink to this reply") At 10:04 AM on Sep 25, 2006, [Levent Gurses](http://www.eclipsezone.com/forums/profile.jspa?userID=185068) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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)](http://www.jacoozi.com/index.php?option=com_content&task=view&id=119&Itemid=134)**

Levent Gurses  
Jacoozi - New Generation E-Solutions for &gt;&gt; Thinking Companies  
[www.jacoozi.com](http://www.jacoozi.com)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92143074 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92143074 "Click to reply to this thread")

[10.](http://www.eclipsezone.com/eclipse/forums/t53459.html#92143074 "Permlink to this reply") At 10:18 AM on Apr 24, 2007, [sumedh](http://www.eclipsezone.com/forums/profile.jspa?userID=226586) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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.

- [![Attachment](http://www.eclipsezone.com/servlet/JiveServlet?attachImage=true&contentType=image%2Fjpeg&attachment=7539)](http://www.eclipsezone.com/servlet/JiveServlet/download/18111-53459-92143074-7539/remote_debug.jpg) [remote\_debug.jpg](http://www.eclipsezone.com/servlet/JiveServlet/download/18111-53459-92143074-7539/remote_debug.jpg) (146.0 K)

[]()

  [![Click to reply to this thread](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92154769 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92154769 "Click to reply to this thread")

[11.](http://www.eclipsezone.com/eclipse/forums/t53459.html#92154769 "Permlink to this reply") At 11:10 AM on Jun 12, 2007, [dushyant](http://www.eclipsezone.com/forums/profile.jspa?userID=232143) ![Javalobby Newcomers](http://www.eclipsezone.com/images/status/star_yellow_new.gif "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](http://www.eclipsezone.com/images/std/icons/write_16x16.gif)](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92161965 "Click to reply to this thread") [Reply](http://www.eclipsezone.com/forums/post%21reply.jspa?messageID=92161965 "Click to reply to this thread")

[13.](http://www.eclipsezone.com/eclipse/forums/t53459.html#92161965 "Permlink to this reply") At 5:36 PM on Jul 18, 2007, [Alex Blewitt](http://www.eclipsezone.com/forums/profile.jspa?userID=183608) ![DeveloperZone Top 100](http://www.eclipsezone.com/images/status/dz100.gif "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.