About JAVA.LANG.CLASSCASTEXCEPTION:XXX cannot is cast to Javassist.util.proxy.Proxy

Source: Internet
Author: User

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

Related Article

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.