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?
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.
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
Related
I am working on moving code from R2007a to R2013a. I am getting a java.lang.NoClassDefFoundError during my run in R2013a which does not appear in R2007a. It occurs when I call.
feval('get',fname,jevent);
Where fname is a product.ProxyField object for an Object Filter and jevent is a product.format.java.internal.JavaEvent.
The class is in a jar file on the path and is being accessed by another class in the same jar file. The stack trace does not leave the realm of the product if that helps.
I do not have access to the original code for the jar file. I do have access to code derived from that original code and both classes are in the same package. I'm guessing this has something to do with differences in the java version but I'm not sure what to do since I don't have the original code to recompile.
Unfortunately I can't provide actual source or full detail but a google search only yielded results for MATLAB startup issues. Any thoughts?
Seems like the difference between R2007a and R2013a is that the first uses 1.5 jre and second uses 1.6 jre. It would be easier to help you if you provided the stack trace showing the exception. Sometimes classes get moved around in between jvm versions, so having the actual missing classes would help in determining if the missing class is a class that was just moved around to a different package. You could take the missing class, google it adding the same exception message as you put above and seeing who else ran into similar issues.
I am trying hard to find the cause of a weird JSF error. To do this, I try to debug the source code inside javaee-web-api module where a NullPointerException is thrown during JSF rendering. But I am stuck because the debugger does not show me the source code of that location.
There is a discussion thread that says that javaee-web-api is stripped (no bytecode for methods) and meant to be used only for compilation.
What does this mean? Can someone explain it in more detail? I want to understand why I cannot debug the location where that NullPointerException is thrown. I think this is related to the fact that these JARs are stripped.
Normally, the class files in a jar file will contain information on the line numbers relating to the code in the class - this is called the debug information. A stripped jar simply does not have this information.
You are correct in assuming this is the problem. The stack trace you see won't contain any line numbers relating to the code in the stripped jar. Since the jar is provided by a third-party, there's nothing you can do to get that information.
Am using my java application with log4j as logging mechanism
For most of the debug statements of the 3rd party jars am using, am getting filename with line numbers like
com.abc.xyz.GG(doFilter:67)
but for my source code, am getting the following
com.xyz.abc.class (unknown source problem)
Its tough for me to debug my source code since there is no line number info.
Can Someone please help me how do I enable this....
Thanks in advance....
Did you compile your code with the "-g:none" option of javac?
If so, the compiler doesn't generate any debugging information and Log4j cannot fetch them.
You need to pass -g option when calling the javac command.
From the Oracle documentation:
-g
Generate all debugging information, including local variables. By default, only line number and source file information is generated.
If you using ant to build your project you need to set the javac task's debug attribute to on, like this:
<javac debug="on">...</javac>
While compiling my project I get:
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.code.Type$WildcardType.isSuperBound(Type.java:435)
at com.sun.tools.javac.code.Types$1.visitWildcardType(Types.java:102)
at com.sun.tools.javac.code.Types$1.visitWildcardType(Types.java:98)
at com.sun.tools.javac.code.Type$WildcardType.accept(Type.java:416)
at com.sun.tools.javac.code.Types$MapVisitor.visit(Types.java:3232)
at com.sun.tools.javac.code.Types.upperBound(Types.java:95)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2977)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2977)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2977)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
...
How do you find the root of the problem?
I have found a bug report...
The bug report you linked to indicates that the bug was fixed in JDK 6. Which version of the JDK are you using to build?
If you can't identify the part of your source that is causing the problem, perhaps you could try compiling with JDK 6 to see if it can identify the problem without crashing.
Otherwise, I would use the "divide and conquer" approach: Remove half your source code, compile, and see if it still crashes. Depending on whether it does or not, you will know which half the problem is in. Repeat.
I would start by running javac with the -verbose option to see which .java file was causing the problem.
What about trying a different compiler, like the one in Eclipse? It's error messages are at least different, in my experience often more to the point. Also I haven't seen compilation failures like this yet.
Quoting, Sun's Official Java Tutorial
Class names, 'HelloWorldApp', are only
accepted if annotation processing is
explicitly requested
What does it mean? And how to apply it?
"Annotation Processing" is a hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then (by producing compiler errors, compiler warning, emitting source code, byte code ...).
API reference: javax.annotation.processing (Java Platform SE 6).
From the very next line of the page that you refer to:
Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested
If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorldApp.java not javac HelloWorldApp.
That is, the string that you are referring to is a possible error that you might get when trying to compile the examples. The very next line in the document, tells you how to resolve the issue.
If you want to know more about annotations, what they are, and how to use them, then I would suggest to go through the Annotations tutorial.
This error is due to incorrect use of java compilation command i.e javac with file name w/o java extension (.java)
Use proper compilation command
javac HelloWorldApp.java
Command used foe execution
java HelloWorldApp