Because we use our data models as our messaging models and the problem is
when you couple this with Hibernate...since we are using AOP Pointcuts, the
transaction begins after CXF/JAXB has done the unmarshalling and the
transaction ends before CXF/JAXB has done the marshalling.  Therefore any
lazy loaded objects that have not been touched throw a
LazyInitializationException. 



I want to be able to start a transaction thru a CXF interceptor/servlet, and
then end the transaction after the marshalling has happened (but still be
able to through a SOAP Fault if the transaction fails.   

Would this be easier with a filter or through interceptors? 

If through interceptors, any suggestions as to what phase I would need to do
it so that I can keep the transaction open while the JAXB marshals the
response and make sure a SOAP Fault still is thrown for a transaction error.

I have tried creating my own version of the OpenSessionInViewFilter (to
supplement JPA) and it doesn't work, I still get an
LazyInitializationException (even with singleSession=true), I assume because
my JTA is closing the Session.

I tried an older suggestion using HibernateInterceptor and proxying the
service impl and that didn't work either, got the same
LazyInitializationException.

So the only way I currently have to solve this is an internally created
touch method that has to touch (call a get, size, or Hibernate.initialize)
on any object in the graph that hasn't been fulfilled.  Otherwise the
Session is closed, and the JAXB process takes over walking the whole object
graph and throwing LazyInitializationExceptions when it hits a Hibernate
Proxy.

So mainly I need to move the transaction up a level or so where CXF/JAXB has
completed marshalling to XML, lazy loading any outstanding relationships.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/CXF-JAXB-and-Hibernate-LazyInitializationException-tp5713130.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to