Exception key Information:
Java.lang.classcastexception:xxx.xxx.xxx.usermanagemententity_$$_javassist_4 cannot is cast to Javassist.util.proxy.Proxy
There are two possible types of exceptions:
1, Jar package conflict (this may be relatively large, this is the case I encountered)
Because Hibernate and struts2 both need to Javassist-xx.jar, first confirm that the project is not introduced more than one, keep a high version on the line.
2, lazy loading abnormal (this thing I have not met, the internet said so do)
If there is no jar package conflict, it may be lazy loading problem, lazy loading at first only returned a proxy object, then to access the object's specific properties, it will actually load the object, but at this time Sessionfactory is closed, of course, GG. With a filter in Web. XML, the end time of the session can be extended, as follows:
<!--spring filters for lazy loading issues-- <filter> <filter-name>opensessioninviewfilter</ Filter-name> <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter< /filter-class> </filter> <filter-mapping> <filter-name> opensessioninviewfilter</filter-name> <url-pattern>*.action</url-pattern> </ Filter-mapping>
Note that this filter should be placed in front of the struts2 filter , because When the Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter executes, the page will come out, and sessionfactory close after the page has finished loading ( Executes the STRUS2 filter in the Finally method), this time the object data will be lazy loading exception. (You can refer to the order of the finally execution of the filter)
About JAVA.LANG.CLASSCASTEXCEPTION:XXX cannot is cast to Javassist.util.proxy.Proxy