Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
I am getting the following exception. Please let me know what am I missing? Thanks in advance.
Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class.getConstructor0(Class.java:2699) at java.lang.Class.getDeclaredConstructor(Class.java:1985) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:757) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:722) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:267) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
Related Post
Comments
4 Responses to “Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException”
Leave a Reply
You are missing ehcache.jar from your class path. You must include this jar to get rid of the exception. If you don’t have this jar, you can download it from here
Since you are getting NoClassDefFoundError and not ClassNotFoundException, it means the JAR is there in your classpath but classloader is not able to load this class. May be due to version mismatch. Like you are using JDK1.4 and trying to use a class complied in JDK1.5 or above version. Link might help:
http://www.jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror
This problem is realated to Classloading problems – you have the two jars inside different classloaders . Make sure that Hibernate and ehcache jar are in the same dir (thus the same classpath and classloader) and make sure there are no duplicates or older versions.
i also have the same problem
In command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;
it works.