cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mustafa Sezgin" <msez...@aconex.com>
Subject RE: CXF and Hibernate
Date Sun, 19 Jul 2009 23:55:16 GMT
Its because the session is not open when the marshalling occurs. You
either need to evict the entity from the session (not 100% sure this will
work) or use the OpenSessionInViewFilter. 

-----Original Message-----
From: Suneet Shah [mailto:suneetshah2000@gmail.com] 
Sent: Saturday, 18 July 2009 1:37 AM
To: CXF User Group
Subject: CXF and Hibernate

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.ja
va:74)
at 
com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBo
dy(SingleElementNodeProperty.java:126)
at 
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoI
mpl.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

Mime
View raw message