File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problems to find NullPointerExceptions in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems to find NullPointerExceptions in Servlets" Watch "Problems to find NullPointerExceptions in Servlets" New topic
Author

Problems to find NullPointerExceptions in Servlets

Michael Ponewa�
Greenhorn

Joined: Aug 15, 2006
Posts: 2
This is a problem i had several
years with servlets. We have a couple
of servlets which not use any
mvc-framework and are extended
from HttpServlet. In the processRequest
Method which is used from a Get or
Post Request we examine request values,
delegate database calls to DAOs and
collect informations for the view.
The view will be called with a
Dispatcher Forward at the end of method
processRequest.
Now the problem:
Sometimes when i have done some code
change and test i got NullPointerException
in the processRequest Method. Actual not
really a problem to find why - but the processRequest
Method is sometimes 50-100 lines and my
servlet containers log messages like this:

Servlet-Name: frontController which extends HttpServlet

servlet frontController threw exception
java.lang.NullPointerException at lv.ais.requestCover.servlets.frontController.processRequest(Unknown Source)

So why does the servlet container not log the
line where the exception occurs?


regards Michael
[ August 15, 2006: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can control how much debugging info gets compiled into your classes.
Add the -g switch when compiling with javac and your classes will retain all debugging info.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Michael Ponewa�
Greenhorn

Joined: Aug 15, 2006
Posts: 2
Thanks! changed javac property with debug informations
in ant build file. Now i get the source position where
the exception occurs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems to find NullPointerExceptions in Servlets