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>

Related Posts:

  • Creating our Own Hibernate Template classLet us see how to develop our own Hibernate Template class.HibernateTemplate.javaimport java.io.Serializable;import java.util.List;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Sessio… Read More
  • Explain about Hibernate Object Life Cycle?In hibernate object life cycle, mainly consists of four states. They are Transient State, Persistent State, Detached State and Removed State.Hibernate Object Life Cycle1. New or Transient State:When ever a… Read More
  • Hibernate Object Identity and EqualityThere are several mismatches between the Object oriented system and Relation system. In that one of the important mismatch is Object identity and equality.There are three ways to tackle identity: two ways in java world, and o… Read More
  • Different ways to get the Connection object using HibernateGetting the java.sql.Connection object using Session:---------------------------------------------------------------------------org.hibernate.Session is nothing but get the one physical connection from the database. By u… Read More
  • CRUD Operations Using HibernateBelow example explains how to perform Create, Read, Update and Delete (CRUD) operations using Hibernate.Tools: Eclipse,MySQLHiberante 4.3.6Project Structure:Step1: Creating the POJO classEmployee.javapackage com.var… Read More

0 comments: