Mantis - Hessian
Viewing Issue Advanced Details
4011 major always 04-21-10 05:33 06-06-12 01:06
schatterjee  
 
normal  
new 3.1.6  
open  
none    
none  
0004011: Server Exceptions Not getting passed to client (Found root cause and possible Fix)
Problem Description
-------------------
Server side exception could not be serialized to cilent side.
Even if we throw SabaException from our Server, the client is receiving ?org.springframework.remoting.RemoteAccessException?.


Root Cause
-----------
1. On investigation we found that there were a problem in serialization of exceptions in Hessian 2.0 Protocol.
2. Hessian was using buffers to serialize the exception and the buffer was flushed to output streams only if the buffer was full.
3. There was a problem during serialization of StackTraceElement
4. On completion of serialization the buffer was not flushed, due to which incomplete serialized exception was being sent to client.
5. As a result client gets exception ?readObject: unexpected end of file? while de-serializing the exception and it results in RemoteAccessException

Solution
-------
1. We fixed the issue by adding a flush() statement at the end of writeFault() method in Hessian2Output.java

Please advise if this fix is right or not and when can we expect a formal fix for this.


I have attached both the original source code and modified source code for Hessian2Output.java
There is already a bug reported for same error -> 0003030: Server side exception could not be serialized to cilent side. (http://bugs.caucho.com/view.php?id=3030) [^]


 Hessian2Output_Fixed.java [^] (34,813 bytes) 04-21-10 05:33
 Hessian2Output.java [^] (34,822 bytes) 04-21-10 05:33

Notes
(0004539)
schatterjee   
04-21-10 05:39   
I am using Hessian 3.1.6 and Spring 2.5.2

Related bug reported earlier --> http://bugs.caucho.com/view.php?id=3030 [^]

(0005807)
ccampo   
06-06-12 01:06   
We had the same kind of problem. However I think the problem is different one. The problem is that the HessianServlet does not close the out.stream if there is an exception.

HessianServlet calls out.close() (line 398) only if everything is ok. In the case of an exception no close is called and no buffer is flushed. So the correct solution is to put the out.close in a finally {} block in HessianServlet. (We replaced HessianServlet with our own implementation and did just that.