Hibernate Error – Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter

A common Hibernate’s error, this is caused by the missing dependency library – cglib.


Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.mkyong.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
	at com.mkyong.persistence.HibernateUtil.<clinit>(HibernateUtil.java:8)
	at com.mkyong.common.App.main(App.java:17)
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
	at org.hibernate.bytecode.cglib.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:33)
	at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:182)
	at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:160)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
	at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
	at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
	at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
	at com.mkyong.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
	... 2 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.CallbackFilter
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 15 more

Solution

You can download the library here – http://cglib.sourceforge.net/

Or

Add the dependency in Maven’s pom.xml


       <dependency>
		<groupId>cglib</groupId>
		<artifactId>cglib</artifactId>
		<version>2.2</version>
	</dependency>

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
3 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
http://www.seattleluxuryrealestateauction.com/blog/entry/real-estate-auction-activityDebabrata PatnaikHibernate Tutorials | Tutorials Recent comment authors
newest oldest most voted
http://www.seattleluxuryrealestateauction.com/blog/entry/real-estate-auction-activity
Guest
http://www.seattleluxuryrealestateauction.com/blog/entry/real-estate-auction-activity

Hi there, I found your blog by way of Google even as searching for a similar matter, your
site came up, it looks great. I have bookmarked it in my google bookmarks.

Hi there, simply was alert to your blog through Google, and found that it’s really informative. I am going to be careful for brussels. I’ll be grateful if you
happen to proceed this in future. A lot of other people will likely be benefited from your writing.
Cheers!

Debabrata Patnaik
Guest
Debabrata Patnaik

Hi MKYONG thanks for such a simple solution. Really helped to solve the issue. Can you provide pointer to learn more about CODE GENERATION LIBRARY in details.

trackback
Hibernate Tutorials | Tutorials

[…] java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter […]