1

I'm using Method.invoke() to call a function in a third party jar. Sometimes I get a java.lang.reflect.InvocationTargetException thrown. How can you figure out what the real exception was from this?

gparyani
  • 1,958
  • 3
  • 26
  • 39
Heinrich Schmetterling
  • 6,614
  • 11
  • 40
  • 56

1 Answers1

5

InvocationTargetException.getCause() it uses the normal exception chaining stuff introduced in 1.4

Francis Upton IV
  • 19,322
  • 3
  • 53
  • 57
  • There's also getTargetException() but the javadoc indeed suggests to use getCause() that was introduced later. – ewernli Dec 01 '09 at 07:52