I'm trying to setup a 3 tier application using OpenSwing.
On the serverside I use the OpenSwing Controller together with hibernate as ORM tool.
I'm using the Hessian library to do the serialisation/deserialisation over HTTP.
If the client recieves the response and tries to deserialize it, it throws a ''lazy initialization exception", of course, because there is no open session on the client...
I found this thread
that suggests to take out the hibernate jar file on the client because Hessian would then switch to a default collection(?).
When I try this it gives a 'java.lang.ClassNotFoundException: org.hibernate.proxy.HibernateProxy' is not defined.' exception...
I found another thread that suggests to set all referenced collections of the object to 'null', I hope there is a better solution?
Any help would greatly be appreciated!
The issue you reported is well known when developing applications using an ORM, such as Hibernate, where more than one tier is involved
on the entity beans usage, therefore in OpenSwing 3tiers applications too.
Usually I follow both these rules:
- never use lazy initialization when retrieving entities from the ORM; this avoid to fire a 'lazy initialization exception' on the client-side
- include hibernate.jar and other dependencies libraries in client-side tier; this avoid to fire ClassNotFoundException on the client-side