Hello

I have a number Spring / Hibernate pojos that I am exposing as webservices using CXF. However, I am running the following problem and was wondering if someone on the list may have any suggestions on how I can work around this.

Group class
- collection of Users
- Attributes
There is a many to many relationship between User and Group and I am using lazy loading to avoid having to load users until its necessary.

However, when I call an operation that returns a Group or a list of Groups, I get the following error.

Caused by: com.sun.xml.bind.api.AccessorException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: Group.users, no session or session was closed at com.sun.xml.bind.v2.runtime.reflect.AdaptedAccessor.get(AdaptedAccessor.java:74) at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:126) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)

I suspect that is happening when cxf marshalls the object and hibernate has problem because the dependant objects have not been initialized. How can I work around this? I don't want to have to load the user collection just to marshall the object.

How are other people addressing this type of problem?

Thanks

Reply via email to