reset password
Author Message
cysun
Posts: 2935
Posted 00:06 May 11, 2010 |

The number one thing in debugging is to find out what went wrong, and to do that you must read the error messages carefully, very carefully.

There are some common errors when you debug CSNS:

404 Errors

There are several types of 404 errors:

1. The application failed to start.

Look for the error message in Eclipse's Console View. Usually the cause of the error is that one of the Spring beans failed to initialize because of missing getter or setter or something.

2. The request is not mapped to a controller/view.

Remember that a request must go through three levels of mapping - it's first mapped to Spring's front controller in web.xml, then mapped to a controller in spring-servlet.xml, then a view name is resolved to a JSP file. Double check these mappings when you encounter this type of 404 errors.

3. Mysterious 404 errors.

Sometimes the project fails to start, but the Console View either show no error message or some weird error message that doesn't seem to make sense. This may be because Eclipse got into some error state that it couldn't recover from. Cleaning the project work directory usually solves the problem.

Runtime Errors

Check out the log file (csns.log). The exception stack trace in the log is usually clear enough for you to locate the problem.

Install and use the Logfile Viewer plugin - it'll save you tons of time.

JSP Errors

The error messages are shown in the browser. Usually it's some problem with the custom tags, e.g. missing closing tag and so on.

Logical Errors

The logic of web applications is usually pretty straightforward, but once in a while you may run into some logical errors. You can use Eclipse's Debug Perspective to trace the application line by line.

First, double click the left end of a code line to create a break point, then right click on the project and select "Debug on Server" (instead of "Run on Server"). Once the execution reaches the break point, Eclipse will switch to the Debug Perspective, and you can use Step Into/Over to step through the code line by line until you find the problem.

In addition to your IDE, also take advantage of your browser during debugging. For example, View Source often reveals the problem when a page doesn't display what it's supposed to display, and Firefox have a Error Console that displays all the JavaScript errors/warning and so on.

Last edited by cysun at 15:16 May 12, 2011.