PDA

View Full Version : Exception Handling at the Server Classes


GauravSinghal
02-21-2007, 11:22 AM
Hi,
We have used Spring Framework Remoting for our project, the problem I am facing is that whenever there is an exception raised at the server classes, it always comes as RemotingException to the client. And on top of that all the stack trace and the information of the Exception is lost.
Please let me know if there is a way in which I can send the custom exception from the server to the client, I believe we can do that in .Net remoting. But want to understand how to accomplish in Spring Framework.
Any pointers or code snippet will be very helpfull.

Thankyou,
Gaurav Singhal

Erich Eichinger
02-22-2007, 08:33 AM
Hi,

Try marking your custom Exception as [Serializable]. This has most likely nothing to do with spring.

cheers,
Erich

Bruno Baia
02-22-2007, 05:09 PM
From MSDN :
Exception Management in .NET (http://msdn2.microsoft.com/en-us/library/ms954599.aspx)
( Chapter "Remoting Custom Exceptions" )


The Exception class implements the ISerializable interface, allowing it to manage its own serialization. To allow your exceptions to be marshaled across remoting boundaries, you need to attribute your class with the [Serializable] attribute and include the additional constructor shown below.

protected YourBaseApplicationException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}




Hope this helps,
Bruno