Mantis - Hessian
Viewing Issue Advanced Details
4027 major always 05-05-10 00:12 05-05-10 00:12
halid  
 
normal  
new 4.0.3  
open  
none    
none  
0004027: Client gets RemoteException instead of BusinessException
Description:

Our service on the server site throws a declared BusinessException. Hessian Skeleton on the server site does not correct serialize the exception and we get a RemoteAccessException on the client site instead of BusinessException.

Possible Fix
------------
Root of the problem seems to be a bug in following code-snippet inside of HessianSkeleton:
8<--------------------------------------------------------------------
297 try {
298 result = method.invoke(service, values);
299 } catch (Exception e) {
300 Throwable e1 = e;
301 if (e1 instanceof InvocationTargetException)
302 e1 = ((InvocationTargetException) e).getTargetException();
303
304 log.log(Level.FINE, this + " " + e1.toString(), e1);
305
306 out.writeFault("ServiceException", e.getMessage(), e);
307 out.close();
308 return;
309 }
-------------------------------------------------------------------------->8

In the line 301 is an InvocationTargetException (e) detected and in the following line is the target exception (exception throwed by service) extracted and assigned to the variable e1.
But in the line 306 (out.writeFault....) the InvocationTargetException (e) will be serialized instead of extracted BusinessException (e1).
We fixed the issue by replacing the variable e with the variable e in this line:

out.writeFault("ServiceException", e.getMessage(), e);
Java Runtime: Sun jdk1.5.0_16
OS: Windows XP
Hessian: 4.0.3

There are no notes attached to this issue.