org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session 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$$e10be950.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)
分析原因:
由于Spring控制的Hibernate的生命周期只针对数据层和服务层,而未管理到表现层,所以会出现the owning Session was closed的现象。针对这一点,我通过hibernate filter的方式来解决。
解决方法:
在web.xml中配置filter来解决。
<!-- 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 </ filter-name >
< url-pattern > *.do </ url-pattern >
</ filter-mapping >
分享到:
相关推荐
解决org.hibernate.LazyInitializationException: could not initialize proxy - no Session...
NULL 博文链接:https://smartgwt.iteye.com/blog/1252268
并且对Dao和Service进行了封装,内含.jar包,并且解决了一对多双向关联的could not initialize proxy - no Session错误,同时解决了……invoked on net.sf.json.JSONException: There is a cycle in the hierarchy!...
主要介绍了Plsql Developer连接Oracle时出现Could not initialize oci.dll解决方案,需要的朋友可以参考下
解决:oracle_plsql连服务端时 Initialization error could initialize错误处理方法
监听COM口启动程序报错 Could not initialize class gnu.io.RXTXCommDriver异常 是因为需要在%JAVA_HOME%/jre/bin目录中添加rxtxParallel.dll、rxtxSerial.dll文件
内涵jacob_1.14.3-x64.dll;jacob_1.14.3-64.jdk(maven地址);解决方法:Could not initialize class com.jacob.com.ComThread
初始化数组,对于在VC++编译环境下,该代码是非常有帮助的,可以让读者快速学习数组的应用。
使用javacpp技术,在32位linux系统上实现视频截图功能,注意so文件放在liberary_path里面
Could not initialize "D:\app\Happy\product\11.2.0\dbhome_1\bin\oci.dll" Make sure you have the 32 bits Oracle Client installed. OracleHomeKey: OracleHomeDir: D:\app\Happy\product\11.2.0\dbhome_1 ...
java.lang.NoClassDefFoundError: Could not initialize class org.apache.derby.jdbc.AutoloadedDriver40 导致的原因: 在azkaban的server和executor中缺少一个叫derby.jar的包
7.注册如果发送邮件激活的方式出错(返回页面错误org.hibernate.LazyInitializationException: could not initialize proxy - no Session) 8.禁止用户后不允许登录、发帖、回帖等 9.后台会员搜索中文名搜索乱码 ...
instantclient-basic-windows.x64-11.2.0.4.0
IDA6.4中支持pin的动态二进制插桩功能,这是其中的描述文档
Win7 x64 PL/SQL 连接 Oralce 提示 Could not initialize "%ORACLE_HOME%\bin\oci.dll" 缺少oci文件
unable to initialize windows sockets interface error code 0 WINSOCK坏了
JSONArray.fromObject(map)报错:Could not initialize class net.sf.json.JsonConfig。ireport 需要高于2.1版本的包。于是就找了这些包。最后2.2.2适合
// Initialize the proxy server // Also specify any options for hyperswarm here // https://github.com/hyperswarm/hyperswarm const server = new HyperswarmServer ( ) // Start listening on clients via ...
由于找不到vcruntime140_1.dll,无法继续执行代码。解决方法:将缺失的文件`vcruntime140_1.dll`复制到C:\Windows\System32目录下(32位操作系统需复制到C:\Windows\SysWOW64)即可解决。