6 Replies Latest reply on Jan 4, 2009 12:26 PM by ryanrlamothe

    Cache service not registered on cold start EAR persistent un

    ryanrlamothe

      I have been working to enable Hibernate second-level entity caching for use with our detached entities.

      Server: JBossAS 4.2.2
      Cache: 1.4.1 (included version in JBossAS 4.2.2)

      The behavior that I am seeing is that if I cold start the container with no EAR deployed, everything starts fine, including the cache. Then I deploy the EAR and the persistence unit deploys fine and finds the cache service MBean.

      Now, if deploy the EAR and cold start the container the persistence unit fails to load because it cannot find the cache service. The exception is as follows:

      javax.persistence.PersistenceException: org.hibernate.cache.CacheException: java.lang.RuntimeException: Error creating MBeanProxy: jboss.cache:service=EJB3EntityCache

      Hot deploy the EAR and the persistence unit will be found.

      How do I configure either JBoss or my EAR/persistence to depend on the cache being completed deployed before the EAR?

      If you need me to post any files, please let me know. Thanks!

        • 1. Re: Cache service not registered on cold start EAR persisten
          ryanrlamothe

          Caused by: javax.management.InstanceNotFoundException: jboss.cache:service=EJB3EntityCache is not registered.

          • 2. Re: Cache service not registered on cold start EAR persisten
            ryanrlamothe

            I tried placing the MBean definition in the default/conf/jboss-service.xml file instead of a standalone cache-config.xml file in /default/deploy but got a different error relating to TransactionManager being NULL at runtime.

            • 3. Re: Cache service not registered on cold start EAR persisten
              ryanrlamothe

              Here is my persistence.xml file:

              <?xml version="1.0" encoding="UTF-8"?>
              <persistence 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
               http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
              
               <persistence-unit name="testPU" transaction-type="JTA">
               <jta-data-source>java:/testDS</jta-data-source>
               <properties>
               <property name="hibernate.cache.use_second_level_cache" value="true"/>
               <property name="hibernate.cache.provider_class" value="org.jboss.hibernate.jbc.cacheprovider.JmxBoundTreeCacheProvider" />
               <property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityCache" />
               </properties>
               </persistence-unit>
              
              </persistence>


              • 4. Re: Cache service not registered on cold start EAR persisten
                ryanrlamothe

                I changed the following line with no change in behavior:

                <!--<property name="hibernate.cache.provider_class" value="org.jboss.hibernate.jbc.cacheprovider.JmxBoundTreeCacheProvider" />-->
                <property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook" />


                • 5. Re: Cache service not registered on cold start EAR persisten
                  jaikiran

                  Looks like a deployment ordering issue. I can think of two options:

                  1) Create a folder named "deploy.last" in server/default/deploy folder and place your EAR file in that deploy.last folder. That way, your EAR will be deployed after everything else is deployed

                  OR

                  2) Create a jboss-app.xml (if you dont already have one) and place it in the META-INF of your EAR. The jboss-app.xml can contain the following:

                  <jboss-app>
                   <module>
                   <service>cache-config-service.xml</service>
                   </module>
                  </jboss-app>


                  And package that cache-config-service.xml at the root of your EAR.


                  • 6. Re: Cache service not registered on cold start EAR persisten
                    ryanrlamothe

                    jaikiran,

                    Our deployment scenario excludes Option #1, but Option #2 worked perfectlty!!! Thank you!!!

                    I searched for hours for that information. Where is that located in the documentation?

                    Again, thank you!!!