Thanks Cyrille and Richard.
That worked.
Suneet
Cyrille Le Clerc wrote:
Hello Suneet,
It looks like you need a kind of OpenSessionInViewFilter to have an
Hibernate session available during the CXF marshalling phase.
More details here :
http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html
Hope this helps,
Cyrille
*Cyrille Le Clerc*
[image: Xebia IT Architects] <http://www.xebia.fr>
Email :
Tél :
Mobile :
Web :
[email protected]
+33(0)1 46 91 76 16
+33(0)6 61 33 69 86
www.xebia.fr
blog.xebia.fr
*Siège Social*
La Défense Colisée
10 / 12 Avenue de l'Arche
Faubourg de l'Arche
92419 Courbevoie Cedex
[image: Xebia blogue !]<http://feeds.feedburner.com/%7Er/XebiaFrance/%7E6/4>
On Fri, Jul 17, 2009 at 5:36 PM, Suneet Shah <[email protected]>wrote:
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