While working with hibernate this error can be faced. This is because absence of ‘common-collections.jar’ in your classpath.
01 Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap 02 Exception in thread "main" java.lang.ExceptionInInitializerError 03 at hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:18) 04 at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:8) 05 at driver.Driver.main(Driver.java:14) 06 Caused by: java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap 07 at org.hibernate.util.SimpleMRUCache.init(SimpleMRUCache.java:71) 08 at org.hibernate.util.SimpleMRUCache.<init>(SimpleMRUCache.java:55) 09 at org.hibernate.engine.query.QueryPlanCache.<init>(QueryPlanCache.java:76) 10 at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:239) 11 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872) 12 at hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:15) 13 ... 2 more 14 Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.LRUMap 15 at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 16 at java.security.AccessController.doPrivileged(Native Method) 17 at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 18 at java.lang.ClassLoader.loadClass(ClassLoader.java:307) 19 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 20 at java.lang.ClassLoader.loadClass(ClassLoader.java:248) 21 ... 8 more 22 23
What is Common Collections?
The Java Collection Framework was a major addition in JDK 1.2. It added many powerful data structures that accelerate development of most significant Java applications. Since that time it has become the recognised standard for collection handling in Java.
Commons-Collections seek to build upon the JDK classes by providing new interfaces, implementations and utilities. There are many features, including:
- Bag interface for collections that have a number of copies of each object
- Buffer interface for collections that have a well defined removal order, like FIFOs
- BidiMap interface for maps that can be looked up from value to key as well and key to value
- MapIterator interface to provide simple and quick iteration over maps
- Type checking decorators to ensure that only instances of a certain type can be added
- Transforming decorators that alter each object as it is added to the collection
- Composite collections that make multiple collections look like one
- Ordered maps and sets that retain the order elements are added in, including an LRU based map
- Identity map that compares objects based on their identity (==) instead of the equals method
- Reference map that allows keys and/or values to be garbage collected under close control
- Many comparator implementations
- Many iterator implementations
- Adapter classes from array and enumerations to collections
- Utilities to test or create typical set-theory properties of collections such as union, intersection, and closure
Click here to download and read more about common collections. (From the Apache site.)
Your Suggestions Are Always Welcomed.