InvocationTargetException caused by ArrayIndexOutofBound exception

181 views Asked by At

i have a function where am using methodaccesor's invoke function,the problem is the application which am using is very vast,so there are times when this exception InvocationTargetException is thrown and the cause for this happens to be ArrayIndexOutofBounds Exception. The problem which occurs is comparitively less 8% of the transactions result in this (am unable to replicate this scenario),am unable to figure out what/how is causing this

can you guys please give me suggestions regarding this problem ,as to how to go about it?

am using reflector's PropertyUtils class here getindexedproperty is causing InvocationTargetException the thing am unable to replicate the issue what could be causing this as it happens very rarely

1

There are 1 answers

0
Tom McClure On

You are probably suffering from code that catches exceptions and does not log a proper stack trace.

Change all such instances in your code to do this instead:

try {
    // dangerous stuff here
} catch (SomeException e) {
    // Personally, I like to send a stack trace to stderr.
    // You may prefer to print this to your log, eg if you don't capture stderr,
    // or won't/can't for whatever reason.
    e.printStackTrace(System.err);
}

And you will never again be at a loss as to where in your code these exceptions bubbled up from.

As you visit each try-catch, ask yourself if you should really be robust to such failures; sometimes the best thing is to let the code fail fast and not catch the exception in the first place. When the application fails due to some code/data that was in an incorrect state, you will find out quickly and get a roadmap (stack trace) to the root cause.