Hibernate not obedient--could not initialize proxy-the owning sessions was closed

Source: Internet
Author: User
Tags sessions
Hibernate not obedient--could not initialize proxy-the owning sessions was closed

Development Environment:
Struts 1.2 + Spring 1.2.8 + Hibernate 3.2

the problems encountered:
Org.hibernate.LazyInitializationException:could not initialize Proxy-the owning sessions was closed
At Org.hibernate.proxy.AbstractLazyInitializer.initialize (abstractlazyinitializer.java:60)
At Org.hibernate.proxy.AbstractLazyInitializer.getImplementation (abstractlazyinitializer.java:111)
At Org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke (cgliblazyinitializer.java:172)
At com.zhjy.gea.module.affair.domain.affair$ $EnhancerByCGLIB $ $e 10be950.getaffaircatalogs (<generated>)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)
At Java.lang.reflect.Method.invoke (method.java:585)
At Org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod (propertyutilsbean.java:2049)
At Org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty (propertyutilsbean.java:1286)
At Org.apache.commons.beanutils.BeanUtilsBean.copyProperties (beanutilsbean.java:284)
At Org.apache.commons.beanutils.BeanUtils.copyProperties (beanutils.java:137)

Analysis Reason:
The owning session is closed occurs because the hibernate lifecycle of Spring control is not managed at the layer of data and services, but not the presentation layer. In response to this, I hibernate filter the way to solve.

Workaround:
Configure filter in Web.xml to resolve. <!-- hibernate session filter -->
  < filter >
   < Filter-name > Hibernatefilter </filter-name >
   < filter-class >     Org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
   </filter-class >
  </filter >

< filter-mapping >
   < filter-name > Hibernatefilter </fi Lter-name >
   < url-pattern > *.do </url-pattern >
  </filter-mapping >

Remember here, hope to encounter the same problem friends, less detours. :)
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.