Friday, December 27, 2013

java.lang.NoClassDefFoundError: net/sf/ehcache/util/Timestampe


Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/util/Timestamper at org.hibernate.cache.ehcache.internal.regions.EhcacheDataRegion.<init>(EhcacheDataRegion.java:86)    at org.hibernate.cache.ehcache.internal.regions.EhcacheTransactionalDataRegion.<init>(EhcacheTransactionalDataRegion.java:74)   at org.hibernate.cache.ehcache.internal.regions.EhcacheEntityRegion.<init>(EhcacheEntityRegion.java:58)  at org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory.buildEntityRegion(AbstractEhcacheRegionFactory.java:130)
   at org.hibernate.cache.ehcache.EhCacheRegionFactory.buildEntityRegion(EhCacheRegionFactory.java:48)
   at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:339)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
   at str.ForOurLogic.main(ForOurLogic.java:15)
Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.util.Timestamper
   at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
   ... 9 more


Problem: I am getting the above exception because of ehcache-core version problem. Here the version number is 2.3.1.

Solution: I migrated to 2.3.1 to 2.4.0


Add the below line in dependency section
<dependency>
           <groupId>net.sf.ehcache</groupId>
           <artifactId>ehcache-core</artifactId>
           <version>2.4.0</version>
       </dependency>

Add below lines to repositories section 
       
       <repository>
           <id>sourceforge-releases</id>
           <name>Sourceforge Releases</name>
           <url>https://oss.sonatype.org/content/repositories/sourceforge-releases</url>
       </repository>

0 comments: