Announcement Announcement Module
Collapse
No announcement yet.
how to configure ehcache Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment

          Working...
          X