In our log files we find the following:
[2012-09-24 00:09:32.590 +0000UTC] ERROR host server1 [] [] somepackage.someclass [] [Unknown] [V3rAqPaDvvAAAAExEXhdWGyh] [pjsQwTGHzxcAAAE5j4YdGvWV] "ThreadName" Some error happened: java.lang.ArrayIndexOutOfBoundsException: null
There is only this single line, and NO exception stack trace.
The try
block in which this exception happens is executing dynamically-generated Java byte-code which was created using javassist.
I am wondering about two things:
java.lang.ArrayIndexOutOfBoundsException
: nulllogger.error("message", theException)
inside the catch
block, which ordinarily would lead to a full stack-trace being printed in the log-file.My Questions:
What kind of code can cause a logging output "java.lang.ArrayIndexOutOfBoundsException: null". I try to reproduce this with a test program with no luck. I always get something like "java.lang.ArrayIndexOutOfBoundsException: Index: 3" or similar.
Could the reason for missing stack-trace, be that this code is dynamically generated at runtime, and as such the logger/JVM does not "know" the stack-trace or relevant line number(s)?
We are currently debugging and investigating to get more info, but maybe this sounds familiar to somebody.
String
concatenated with a null
reference might get you such a message:
Object obj = null;
throw new ArrayIndexOutOfBoundsException("" + obj);
If you're using an Oracle JVM you may want to add -XX:-OmitStackTraceInFastThrow
as an additional parameter to see if it helps. For some basic exceptions, the JVM reuses the same exception instance after a while, in which case there's no stack trace anymore. This option prevents the reuse, so you always get a stack trace.
Edit note: this last could also apply to a recent version of OpenJDK (e.g., 1.8)