com.rr.domain.Department_$$_javassist_5 cannot be cast to javassist.util.proxy.Proxy
两个原因:
1、懒加载
在web.xml配置opensessioninviewfilter,须在struts2的strutsprepareandexecutefilter之前配置
1 <filter> 2 <filter-name>OpenSessionInViewFilter</filter-name> 3 <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class> 4 </filter> 5 <filter-mapping> 6 <filter-name>OpenSessionInViewFilter</filter-name> 7 <url-pattern>*.action</url-pattern> 8 </filter-mapping>
2、包冲突
javasisst 两个版本共存了,一个是hibernate的,一个是sturts2的删除低版本。
maven工程的话排除低版本的
1 <!-- struts2 --> 2 <dependency> 3 <groupId>org.apache.struts</groupId> 4 <artifactId>struts2-core</artifactId> 5 <version>${struts.version}</version> 6 <exclusions> 7 <exclusion> 8 <artifactId>javassist</artifactId> 9 <groupId>javassist</groupId> 10 </exclusion> 11 </exclusions> 12 </dependency>
javassist简介
* Javassist, a Java-bytecode translator toolkit.
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.