Configuring Eclipse for Remote Debugging
Pages: 1, 2, 3, 4, 5, 6, 7, 8

Remote Debugging a JBoss Application

Having configured a debug configuration for the example servlet application deployed in the JBoss server, we shall debug the servlet application in the Eclipse IDE. Create a webapp.war web application from the modified (with the NullPointerException) JBossServlet.class file with the build.xml file, as explained in the "Developing a JBoss Application in Eclipse" section. Start the JBoss server. With the debug options specified in the run batch file, the server starts in debug mode.

Next, select the EclipseDebug debug configuration in the Debug frame. Click on the Debug button to connect the remote debugger to the JBoss server, as shown in Figure 16.

Connecting the remote debugger to the JBoss server
Figure 16. Connecting the remote debugger to the JBoss server

This connects the Eclipse remote debugger to the JBoss server. Select the Debug Perspective button to display Eclipse's debug perspective. In the Debug perspective, the remote debugger is shown connected to the JBoss server at localhost, port 8787, as shown in Figure 17.

Remote debugger connected to the JBoss server
Figure 17. Remote debugger connected to the JBoss server

Access the JBossServlet in the JBoss server with the URL http://localhost:8080/webapp/catalog in a browser. Because the servlet throws a NullPointerException, the servlet gets suspended with a NullPointerException, as indicated in the Debug perspective. The line that produced the exception gets displayed, as shown in Figure 18.

JBoss server suspended at NullPointerException
Figure 18. JBoss server suspended at NullPointerException

The line that throws the exception is out.println(str.toString());. The servlet application may be debugged with the different debug options listed by selecting Run in the Eclipse IDE.

Conclusion

We remotely debugged an application deployed to the JBoss server in the Eclipse IDE. An application deployed in another application server such as WebLogic may also be debugged by configuring that server to start in debug mode.

Resources

Deepak Vohra is a NuBean consultant and a web developer.


Return to ONJava.com.