Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my servlet stacktrace show "Unknown Source" for my classes?

I'm currently using Apache Tomcat 5.5.16 to serve a Lucene-based search API.

Lately I've been having some NullPointerExceptions inside my servlet class. The class is called com.my_company.search.servlet.SearchServlet.

With certain types of input I can routinely create a NullPointerException, but I'm having trouble figuring out where exactly it is.

The StackTrace indicates that the bug is occuring here:

com.my_company.search.servlet.SearchServlet.doGet(Unknown Source)

The source and .class files for this class is all in:

$TOMCAT_HOME/webapps/my_servlet/WEB-INF/classes/com/my_company/search/servlet/

My question is, how can I get Tomcat to provide me with more descriptive error locations?

like image 728
zorlack Avatar asked Jun 03 '09 13:06

zorlack


1 Answers

Tomcat cannot provide you more detailed information unless the classes in question were compiled with debugging information. Without this debugging information, the JVM cannot determine what line of code the error occurred on.

Edit: You can ask the compiler to include this information by specifying the -g option when running javac on the command line. You can also specify this option using the debug parameter of the Javac Ant task.

like image 75
Adam Paynter Avatar answered Nov 15 '22 09:11

Adam Paynter