0 Replies Latest reply on Nov 1, 2011 6:22 AM by prabha ramasamy

    caching the entities using EJB 3.0 for JBoss.

    prabha ramasamy Newbie

      We are using the following approach to cache the entities using EJB 3.0 for JBoss.

       

      Persistnce.xml changes :

       

      <persistence-unit name="OracleDatabase" transaction-type="JTA">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <jta-data-source>java:/ClientPointeDS</jta-data-source>

       

        <properties>

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

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

         <!-- These are the default for JBoss EJB3 -->

          <property name="hibernate.cache.provider_class"  value="org.hibernate.cache.HashtableCacheProvider" />

         <property name="hibernate.transaction.manager_lookup_class"  value="org.hibernate.transaction.JBossTransactionManagerLookup" />

                  <property name="jboss.entity.manager.factory.jndi.name"         value="java:/EntityManagerFactories/oracleDatabase" />

       

        

       

         <!--  JBoss Cache Related Changes  -->

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

      <!--   <property name="hibernate.cache.use_query_cache" value="true"/>-->

      <!--   <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"/>-->

      <!--   <property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/>-->

      <!--   <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/>-->

      <!--   <property name="hibernate.cache.region.jbc2.cfg.query" value="local-query"/>-->

      <!--   <property name="hibernate.show_sql" value="true"/>-->

        

        

          <property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook"/>

        

           <property name="hibernate.treecache.mbean.object_name"  value="jboss.cache:service=EJB3EntityTreeCache"/>

          

           <!-- <property name="hibernate.ejb.classcache.services.entities.InstitutionData" value="transactional"/>

            <property name="hibernate.ejb.classcache.services.entities.InstitutionStatus" value="transactional"/> -->

        

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

       

         <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"/>

       

         <property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/>

        

         <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/>

        

         <property name="hibernate.cache.region.jbc2.cfg.collection" value="mvcc-entity"/> 

        

        </properties>

       

       


      @XmlRootElement(name="institutionData")
      @XmlType(propOrder={})
      @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
      public class InstitutionData {

        /**
         * Apache Logger reference
         */ 


      }


       

       

      We are getting the following Exception

       

       

      [SessionFactoryImpl] building session factory

      15:50:44,520 INFO [JndiMultiplexingCacheInstanceManager] Unable to retreive Cache from JNDI [java:CacheManager]

       

       

      [SessionFactoryImpl] building session factory

      15:50:44,520 INFO  [JndiMultiplexingCacheInstanceManager] Unable to retreive Cache from JNDI [java:CacheManager]

      javax.naming.NameNotFoundException: CacheManager not bound

      at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)

      at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)

      at org.jnp.server.NamingServer.getObject(NamingServer.java:785)

      at org.jnp.server.NamingServer.lookup(NamingServer.java:443)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

      at javax.naming.InitialContext.lookup(InitialContext.java:392)

      at org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.locateCacheFactory(JndiMultiplexingCacheInstanceManager.java:83)

      at org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.start(JndiMultiplexingCacheInstanceManager.java:72)

      at org.hibernate.cache.jbc2.JBossCacheRegionFactory.start(JBossCacheRegionFactory.java:106)

      at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)

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

      at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)

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

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

      at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)