0

I am getting this

java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy1.getMyObject(Unknown Source)

I went through a similar post here and this article posted in one the comments .

But in this case the I am calling following method using a ThriftClient which was created using com.twitter.common.thrift.ThriftFactory<T>

myThriftClient.getMyObject()

Is there any way of knowing what is the actual cause of this error ? Should I need to change something in thrift side code ?

Community
  • 1
  • 1
holmes840
  • 1,063
  • 2
  • 11
  • 24
  • "*Should I need to change something in thrift side code ?*" - If you think you found an error in the Thrift code (be it generated or library), please file a JIRA ticket including a test case. If you have a patch proposal or an idea, include that too. Thanks! – JensG Sep 11 '14 at 12:59

2 Answers2

0

It does not seem like this is a Thrift issue at all... it seems like it is inside the library that you are using ("twitter commons" or whatever). I presume that their library is trying to create a dynamic proxy for your interface, but your interface it unable to handle whatever checked exception is being thrown.

You might want to try declaring "throws java.lang.Throwable" on your interface temporarily if you are having trouble ascertaining the underlying exception and are unable to fix the implementation of the Invocation Handler itself. At least the root cause won't be buried by the UndeclaredThrowableException if you do that.

Alternatively, just set a breakpoint in a graphical debugger and step through the invocation to be able to see your program's state.

BCG
  • 1,170
  • 8
  • 19
0

The issue here was that my client side thread was sending a Thread.interrupt() to the myThriftClient thread.

So in that case the Caller class (which in my case was DeadlineCaller) inside the Thrift class was interrupted which resulted in an InterruptedException or a TimeoutException which was bundled and displayed as UndeclaredThrowableEception in the stack.

holmes840
  • 1,063
  • 2
  • 11
  • 24