2 Replies Latest reply on Dec 18, 2012 7:41 PM by Mohammad wrk

    JBoss 7 ignores hibernate.cache.provider_class and uses the default cache provider

    Mohammad wrk Newbie

      I'm trying to migrate an existing app from jboss 5 to jboss 7 and having problem with using EHCache as second level cache provider. What I don't understand is that why JBoss ignores the explicit cache provider (specified using hibernate.cache.provider_class property) and uses the deafult one (infinispan)?

       

      Here is my persistence.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence version="2.0"

        xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence">

        <persistence-unit name="myPU">

        <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>

        <properties>

        <property name="hibernate.show_sql" value="false"/>

       

       

        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />

        <property name="hibernate.hbm2ddl.auto" value="create-drop" />

       

        <property name="hibernate.cache.use_second_level_cache" value="true"/>

        <property name="hibernate.cache.use_query_cache" value="false"/>

        <property name="hibernate.generate_statistics" value="false"/>

        <property name="hibernate.cache.use_structured_entries" value="true"/>

        <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>

        <property name="net.sf.ehcache.configurationResourceName" value="ehcache.xml"/>

        <property name="hibernate.cache.region_prefix" value=""/>

        </properties>

        </persistence-unit>

      </persistence>

       

       

      And here is the stack trace:

       

      11:57:19,418 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-9) MSC00001: Failed to start service jboss.persistenceunit."testEHCache.war#myPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."testEHCache.war#myPU": Failed to start service

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_37]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_37]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_37]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: myPU] Unable to build EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                ... 3 more

      Caused by: org.hibernate.cache.CacheException: Unsupported access type [read-write]

                at org.hibernate.cache.infinispan.entity.EntityRegionImpl.buildAccessStrategy(EntityRegionImpl.java:33)

                at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:340)

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)

                at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                ... 9 more