Results 1 to 5 of 5

Thread: how to configure ehcache

  1. #1

    Smile how to configure ehcache

    hi folks

    i trying to configure a second level cache

    for my application

    i have added two special attributes for this

    <prop key="hibernate.cache.provider_class">org.hibernate .cache.EHCacheProvider</prop>

    <class-cache class="com.deemsys.elearn.test.coursecontent.dao.s ampletest" usage="read-write"/>


    but iam getting error on <class-cache>

    if any body has some sample code

    please send me

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    <class-cache> is in your hbm.xml right? If you put it in a spring config file it won't do anything useful.

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    To save time and hair, take a look at the examples provided with Hibernate (to see how the cache can be configured) and the ones provided with Spring to understand how the integration works. They provide some good starting points for beginners.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4

    Default to to configure ehcache

    thanks for your reply

    now i removed <cache> tag from spring configuration file

    and i have already placed the <cache> tag in the corresponding

    mapping files

    now iam getting error

    like

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext-Arch.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: could not instantiate CacheProvider: org.hibernate.cache.EHCacheProvider
    org.hibernate.HibernateException: could not instantiate CacheProvider: org.hibernate.cache.EHCacheProvider
    at org.hibernate.cfg.SettingsFactory.createCacheProvi der(SettingsFactory.java:326)
    at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:219)
    at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1463)
    at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1004)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.newSessionFactory(LocalSessionFactoryBean .java:825)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:751)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1091)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:396)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:277)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:87)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:72)
    at org.springframework.test.AbstractSpringContextTest s.loadContextLocations(AbstractSpringContextTests. java:135)
    at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.loadContextLocations(Abstract DependencyInjectionSpringContextTests.java:224)
    at org.springframework.test.AbstractSpringContextTest s.getContext(AbstractSpringContextTests.java:115)
    at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp(AbstractDependencyInjec tionSpringContextTests.java:192)
    at junit.framework.TestCase.runBare(TestCase.java:125 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:436)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:311)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:192)
    Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.EHCacheProvider
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:376)
    at java.lang.ClassLoader.loadClass(ClassLoader.java(C ompiled Code))
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:442)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:5 04)
    at java.lang.Class.forName1(Native Method)
    at java.lang.Class.forName(Class.java:180)
    at org.hibernate.util.ReflectHelper.classForName(Refl ectHelper.java:108)
    at org.hibernate.cfg.SettingsFactory.createCacheProvi der(SettingsFactory.java:323)
    ... 27 more

  5. #5
    Join Date
    Jun 2005
    Location
    São Paulo, Brasil
    Posts
    86

    Default

    java.lang.ClassNotFoundException: org.hibernate.cache.EHCacheProvider
    Means that the JVM can't find EHCache. Make sure the EHCache JAR (I believe it's called ehcache-1.1.jar) is in your classpath.
    Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •