Remote Debugging with NetBeans IDE 4.1 and its Bundled Servers

I've been trying to understand remote debugging with NetBeans IDE 4.1, and how this can be achieved for non-standard servers (such as JBoss, Tomcat 4 and JRun4). For the servers that are "officially" supported (i.e., anything can be integrated via Ant, as explained in previous blog entries), the procedure is as follows. I will use this procedure as the basis for understanding how to do it with the others. (The second part of my blog entry from yesterday, about debugging with JRun4, was incorrect, or at least incomplete, and I'm going to have to update it.)
  1. Create and deploy a web application. (For purposes of this procedure, I created the web application described in the NetBeans IDE 4.1 Quick Start Guide for Web Applications. I then deployed the application to both bundled servers.)

  2. In the IDE, go to the Runtime window (Ctrl-5), expand the Servers node, right-click the node for the server, and click Start/Stop Server.

  3. Click Start Server (Debug). This starts the server in debug mode.

  4. In the Output window at the bottom of the screen, you'll see something like this (you'll see the first when starting the Tomcat Web Server in debug mode, and the second for the Sun Java System Application Server in debug mode):

    Listening for transport dt_shmem at address: tomcat_shared_memory_id

    Listening for transport dt_shmem at address: localhost4848

    (To change to a socket connection with a port number, stop the server in the Runtime window, right-click it, choose Properties, and change the Debug settings at the bottom of the Properties dialog box.)

  5. Select Run > Attach Debugger from the main menu.

  6. Choose SharedMemoryAttach in the Connector field and type tomcat_shared_memory_id or localhost4848 in the Name field. (If you're using a socket connection with a port number, choose SocketAttach instead.) You'll see something like this (you'll see the first when attaching to the Tomcat Web Server in debug mode, and the second for attaching to the Sun Java System Application Server in debug mode):

    Attaching to tomcat_shared_memory_id
    User program running
    Attaching to localhost4848
    User program running
  7. Set breakpoints. For example, set them in namehandler.java, if you're using the document mentioned in step 1 above.

  8. In your browser, do something to access the file containing the breakpoints. For example, go to the following URL, if you're using the document mentioned in step 1 above (use the first for the Tomcat Web Server, and the second for the Sun Java System Application Server, assuming you're using the default port numbers):

    http://localhost:8084/HelloWeb/response.jsp
    http://localhost:8080/HelloWeb/response.jsp
  9. In the IDE, you can now step through your code. When using the Sun Java System Application Server, you'll see the following interesting dialog box displayed in the IDE:

Now that I've got this working, I'll start working out how it all works (and if it works) for JBoss, Tomcat 4, and JRun4. Especially in the latter case, I think, there'll be problems (browsing the Internet, I found a few people claiming that debugging isn't supported by JRun4).


Update 04/20/05: Yes, it really works for JBoss, Tomcat 4, and JRun4. And it's pretty similar to how it works for the bundled servers. For details, click here.


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today