Finally I figured out the problem. Its because my service is not a pojo, it implements Remote interface and am using RmiServiceExporter to export it as RMI service since my clients could be non spring aware.
It works fine if my service is a pojo because then the stubs created by spring implements RmiInvocationHandler and this code in RmiClientInterceptor class checks for type of stub
Code:
protected Object doInvoke(MethodInvocation invocation, Remote stub) throws Throwable {
if (stub instanceof RmiInvocationHandler) {
// RMI invoker
try {
return doInvoke(invocation, (RmiInvocationHandler) stub);
}
catch (RemoteException ex) {
throw RmiClientInterceptorUtils.convertRmiAccessException(
invocation.getMethod(), ex, isConnectFailure(ex), getServiceUrl());
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
catch (Throwable ex) {
throw new AspectException("Failed to invoke remote service [" + getServiceUrl() + "]", ex);
}
}
else {
// traditional RMI stub
try {
return RmiClientInterceptorUtils.doInvoke(invocation, stub);
}
catch (InvocationTargetException ex) {
Throwable targetEx = ex.getTargetException();
if (targetEx instanceof RemoteException) {
RemoteException rex = (RemoteException) targetEx;
throw RmiClientInterceptorUtils.convertRmiAccessException(
invocation.getMethod(), rex, isConnectFailure(rex), getServiceUrl());
}
else {
throw targetEx;
}
}
}
}
In my case it always goes in else block as my service implements Remote interface.
Shall I file a bug in JIRA?
Regards,
Kapil