Debugging the JEE Application

In the previous chapter, we learned how to write and run unit tests for Java applications using Eclipse and JUnit. In this chapter, we are going to learn how to use Eclipse to debug JEE applications. Debugging is an unavoidable part of application development. Unless the application is very simple, the chances are that it is not going to work as expected on the very first attempt and you will spend some time trying to find out the reasons why. In very complex applications, application developers may end up spending more time debugging than writing application code. Problems may not necessarily exist in your code, but may exist in the external system that your application depends on. Debugging a complex piece of software requires skill, which can be developed with experience. However, it also needs good support from the application runtime and IDE.

There are different ways to debug an application. You may just put System.out.println() statements in your code and print values of the variables, or just a message stating that execution of the application has reached a certain point. If the application is small or simple, this may work, but this may not be a good idea when debugging large and complex applications. You also need to remember to remove such debug statements before moving the code to staging or production. If you have written unit tests and if some of the unit tests fail, then that may give you some idea about the problems in your code. However, in many cases, you may want to monitor the execution of code at line level or function level and check the values of the variables at that line or in that function. This requires support from the language runtime and a good IDE that helps you visualize and control the debugging process. Fortunately, Java has an excellent debugger, and Eclipse JEE provides great support for debugging Java code.

In this chapter, we are going to learn how to debug JEE applications using Eclipse JEE. We will use the same Course Management application that we built in Chapter 4, Creating JEE Database Applications, for debugging. The debugging technique described in this chapter can be applied to remotely debug any Java application, and is not necessarily restricted to the JEE applications.

In this chapter, we are going to cover the following topics:

  • Setting up Eclipse to debug JEE applications remotely
  • Understanding how to perform different different debugging actions, such as setting breakpoints, inspecting variables and expressions, and stepping through the code
  • Connecting the debugger from Eclipse to an externally running JEE application server
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.237.201