Hibernate: CGLIB Enhancement failed:

Source: Internet
Author: User
Today, I just downloaded the latest version of MyHibernate and created a Spring + Hibernate + Proxool project. At the beginning, I encountered a problem and encountered the following error:

Error Message

22:57:20, 217 WARN [org. hibernate. tuple. PojoEntityTuplizer]-<cocould not create proxy factory for: com. xu. ycoe. impl. UserDaoImpl>
Org. hibernate. hibernateexception: cglib enhancement failed: COM. Xu. ycoe. impl. userdaoimpl
At org. hibernate. Proxy. cgliblzyinitializer. getproxyfactory (cgliblzyinitializer. Java: 132)
At org. hibernate. Proxy. cglibproxyfactory. postinstantiate (cglibproxyfactory. Java: 41)
At org. hibernate. tuple. pojoentitytuplizer. buildproxyfactory (pojoentitytuplizer. Java: 161)
......

This error is officially said: http://www.hibernate.org/116.html#A5

Official statement

If you use lazy loading with proxies (default for all classes in hibernate 3), Hibernate needs to subclass your class at runtime. it can't do this if you have a private no-argument constructor. as per documentation, at least package visibility is required.

However, no matter how you check it, there is no such possibility!
On the Internet, another netizen said:
Http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi? Ubb = next_topic & f = 78 & t = 001663 & go = older

User: Travis Hein

I recently found I was having this problem too, when I was not before.

It turns out that it was something to do with having more than one version of the cglib JAR file in the web app's class path. though I am not sure if it is this jar file, or any of the other jar files that hibernate uses and depends on, as I also had the rest of the hibernate jar files in the class path in a different version.

By removing conflicting versions of the cglib & Other jars, things worked again.

My environment was using tomcat, I had set up my instance to place a bunch of commonly used, third party jar files into $ {catalina_base}/shared/lib folder, since the webapps I was running in this Tomcat instance all were using the same version of hibernate, struts, etc.

(Note that the shared/lib folder is the one on your catalina_base, or instance, not the catalina_home, the installation folder for Tomcat, though most default installed instances, these are the same, just one of those things that drove me nuts at first ...)

With these jar files located here, they are loaded according to the servlet spec/tomcat's class loader tree:
$ {Catalina_home}/common/lib
$ {Cataline_base}/shared/lib
<The webapp>/WEB-INF/lib

This particle war file I was building was packaging (an older version) of hibernate. jar and its supporting third party jar files into the war file.
So something was amiss there; removing them from the jar file (as the newer ones I had in the shared/lib folder wocould provide for my webapp)

I guess one cocould also have removed them from the shared/lib and made each web app have their own copy of the jar files.

I have found though with Tomcat 5, now that it uses commons logging, it likes to have log4j in the common/lib folder.

There are two different versions of cglib. jar in the Application Path
But I haven't found it for a long time...

This time, due to different versions, I thought it may be because the other third-party packages are of different versions, so I checked them carefully. Haha
Hibernate !!!
The compatibility of various versions of Hibernate is indeed not very good, because I just downloaded the latest MyEclipse, so Hibernate in it is also the latest 3.1 (it also contains a 3.0 version ). But it was not very good to work with Spring. I deleted it in the path and changed it to version 3.0. It worked normally immediately. I thought this was the reason, but when I imported Hibernate Advanced Support Liberaries, there is no such error. The new Proxool error is reported:

Error Code

22:46:35, 171 INFO [org. logicalcobwebs. proxool. DBPool]-Shutting down 'dbpool 'pool immediately [Shutdown Hook]
2000-02-27 22:46:35, 203 ERROR [org. logicalcobwebs. proxool. ShutdownHook]-Problem calling "get cause" on IllegalStateException.
Java. lang. reflect. InvocationTargetException
At sun. reflect. NativeMethodAccessorImpl. invoke0 (Native Method)
At sun. reflect. NativeMethodAccessorImpl. invoke (Unknown Source)
At sun. reflect. DelegatingMethodAccessorImpl. invoke (Unknown Source)
At java. lang. reflect. Method. invoke (Unknown Source)
At org. logicalcobwebs. proxool. ShutdownHook. remove (ShutdownHook. java: 40)
At org. logicalcobwebs. proxool. ProxoolFacade. shutdown (ProxoolFacade. java: 238)
At org. logicalcobwebs. proxool. ProxoolFacade. shutdown (ProxoolFacade. java: 220)
At org. logicalcobwebs. proxool. shutdownhook. Run (shutdownhook. Java: 99)
At java. Lang. thread. Run (unknown source)
Caused by: Java. Lang. illegalstateexception: shutdown in progress
At java. Lang. shutdown. Remove (unknown source)
At java. Lang. runtime. removeshudownhook (unknown source)
... 9 more

Depressed... support for advanced functions, forget it, no need for the moment...

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.