Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

you have to add debugging information to your classes. compile them with the option -g:

javac -g YourServlet.java

the location unknown source can occurs when the JIT compiler has optimized your class. At that point the source information is lost. to get the original location, restart the server and retry your test. Most of the time you will get the location in your source

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top