Probably your entity object has a 'lazy loaded' property(ies) which are populated with the values from the database only at the time of their access. And if the hibernate session is already closed at the time of the sterilisation (access of that property) you will get the lazy initialisation exception.
To get rid of this exception you probably have to do one of the following:
- ensure that hibernate session is not closed at the time of the accessing the lazy loaded properties (serialisation)
- initialise lazy loaded properties before the session is closed so that it wouldn't need db access even if the session was closed
- make them not 'lazy loaded'
- don't serialise lazy loaded properties at all