wsky / top-link

embedded duplex multi-channel endpoint and connection management for c#/java/...
6 stars 1 forks source link

got UndeclaredThrowableException in InvocationHandler.invoke implemet by DynamicProxy #18

Closed wsky closed 11 years ago

wsky commented 11 years ago

in DynamicProxy.java

@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        MethodCall methodCall = new MethodCall();
        methodCall.Uri = this.uriString;
        methodCall.MethodName = method.getName();
        methodCall.TypeName = method.getDeclaringClass().getName();
        // do not support method overloaded currently
        methodCall.MethodSignature = null;
        methodCall.Args = args;

        MethodReturn methodReturn = this.invoke(methodCall);

        if (methodReturn.Exception == null)
            return methodReturn.ReturnValue;

        //will course java.lang.reflect.UndeclaredThrowableException
        //throw new RemotingException("invoke got error", methodReturn.Exception);
        throw methodReturn.Exception;
    }
wsky commented 11 years ago

http://stackoverflow.com/questions/5490139/getting-undeclaredthrowableexception-instead-of-my-own-exception

wsky commented 11 years ago
throw methodReturn.Exception;

still got UndeclaredThrowableException while having inner exception from remote

wsky commented 11 years ago

interface not declear custom exception, then throw, the error got

wsky commented 11 years ago

http://amitstechblog.wordpress.com/2011/07/24/java-proxies-and-undeclaredthrowableexception/