1 2 3 Previous Next 35 Replies Latest reply on Mar 19, 2013 4:52 AM by jamesviet Go to original post
      • 15. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
        pbalachandran

        I tried the same setup in standalone mode, where even though I see the MBeans (relating to infinispan) I don't see any statistics.  I believe I have turned on the settings that generate statistics (to be then viewed via JConsole), but I haven't had any luck.

         

        Please see attached files - any help is much appreciated.

         

        Thank you.

        • 16. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
          pferraro

          I don't see a region factory defined in your hibernate.cfg.xml. Without this, Hibernate will default to using a HashMap-based 2nd level cache.

          To use Infinispan as your 2nd level cache provider, add this property:

           

          {code:xml}<property name="hibernate.cache.region.factory_class">org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory</property>{code}

           

          And remove all of the other hibernate.cache.infinispan.* properties.  These settings are configured in the infinispan subsystem in standalone.xml.

          Cache statistics are enabled by default.

          • 17. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
            pbalachandran

            However I read that that factory class (org.jboss.as.jpa. hibernate .infinispan.infinispanregionfactory) wasn't required/deprecated.  Moreover you just indicate a package name - is that accurate?

             

            Please let me know.

             

            Can you point me to one documentation (relating to Infinispan and Hibernate/JPA) that is up to date and accurate.

            • 18. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
              smarlow

              The full class name is here.

              • 19. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                smarlow

                Pradeep Balachandran wrote:

                 

                However I read that that factory class (org.jboss.as.jpa. hibernate .infinispan.infinispanregionfactory) wasn't required/deprecated.  Moreover you just indicate a package name - is that accurate?

                 

                For applications that are using the native Hibernate API directly, you still need to configure the region factory.  If your using JPA, you only need to set the hibernate.cache.use_second_level_cache flag.  I'll clarify this in the JPA documentation link that I previously posted.

                • 20. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                  pbalachandran

                  Thank you for response. 

                   

                  I am trying to get Infinispan/L2 Hibernate in JBoss AS7 work using Hibernate and JPA.  The attached files are for the Hibernate version (the hibernate-cfg.xml has been modified to put in your suggestions from the above post), and if you could look at them and confirm I'd really appreciate it.

                   

                  Further the only JTA property I am currently setting is org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform - is this accurate.

                   

                  I will try out these changes, but I appreciate your help.

                  • 21. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                    pbalachandran

                    I have several issues with the above suggestion:

                     

                    a. <property name="hibernate.cache.region.factory_class">org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory</property>

                    Does not work because, because this is the hibernate jar that I am referencing (as is being used inside JBoss AS7.1.0.Final)


                              <dependency>

                                <groupId>org.hibernate</groupId>

                                <artifactId>hibernate-infinispan</artifactId>

                                <version>4.0.1.Final</version>           

                             </dependency>

                     

                    b. Also can someone tell me what JTA related properties need to be set.  Currently I have the following and have tried variations thereof and nothing works in my hibernate-cfg.xml

                     

                            <property name="hibernate.cache.use_second_level_cache">

                                true

                            </property>           

                           

                            <property name="hibernate.cache.region.factory_class">

                                org.hibernate.cache.infinispan.InfinispanRegionFactory           

                            </property>       

                     

                             <property name="hibernate.transaction.jta.platform">

                                org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform

                            </property>

                     

                    c. Scott's link points to this section in the JBoss/Infinispan document, but when I include these properties, it does not work either.

                     

                    <property name="hibernate.cache.region.factory_class" value="org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory"/>

                    <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate"/>

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

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

                     

                    Thank you.

                    • 22. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                      pbalachandran

                      Scott/Paul:

                       

                      Ok, I got something working, but I am not sure if this is accurate.  Could one of you please verify my hibernate-cfg.xml & my DAO (the one named JTATransactionHibernateManager.java) and tell me if this is accurate. 

                       

                      Also can you also tell me what to look for inside JConsole (please see attached snapshots).  Please refer to attached files.

                       

                      As always, thank you so much for your responses.

                      • 23. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                        pbalachandran

                        I made some changes based on your previous posts, but I am unable to locate org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory (per JBoss documents referenced above).  Instead I am using org.hibernate.cache.infinispan.InfinispanRegionFactory from hibernate-infinispan.4.1.0.Final.jar with JBoss AS 7.1.0.Final. 

                         

                        I still don't see any JMX statistics in JConsole. 

                         

                        Questions:

                         

                        a. Is it ok to use

                        org.hibernate.cache.infinispan.InfinispanRegionFactory from hibernate-infinispan.4.1.0.Final.jar with JBoss AS 7.1.0.Final?

                         

                        b. I read that the Infinispan-Hibernate L2 cache enablement is automatic based on the property hibernate.cache.use_second_level_cache=true.  Does this mean that NO code is required inside the DAO to acutally add the entities into the named cache?

                         

                        c. If everything is working correctly, which JMX module should I be looking at in JConsole, to get the statistics?   If you can reference the images from the prior post, that would tell me where I should be looking.

                         

                         

                        Please advice, and thank you.

                         

                         

                        hibernate-cfg.xml snippet

                        ...

                        <session-factory>

                                <property name="hibernate.cache.use_second_level_cache">

                                    true

                                </property>           

                               

                                <property name="hibernate.cache.region.factory_class">

                                    org.hibernate.cache.infinispan.InfinispanRegionFactory           

                                </property>

                               

                                <property name="hibernate.cache.infinispan.cachemanager">

                                    java:jboss/infinispan/container/hibernate

                                </property>       

                                        

                                <!-- BEGIN JTA ONLY -->        

                                <property name="hibernate.transaction.manager_lookup_class">

                                    org.hibernate.transaction.JBossTransactionManagerLookup

                                </property>

                               

                                <property name="hibernate.transaction.jta.platform">

                                    org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform

                                </property>

                                <!-- END JTA ONLY -->

                        ...

                        <session-factory>

                        • 24. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                          pbalachandran

                          Anyone facing a similar issue?  I tried this in JBoss 7.1.1.Final as well, but no luck.

                          • 25. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                            pbalachandran

                            Could someone please post the following for a working sample.

                             

                            a. hibernate-cfg.xml

                            b. pom.xml

                            c. DAO class

                            d. Which mbean to look for within JConsole.

                             

                            Any other settings that are required with standalone-full-ha.xml.

                             

                            Thank you.

                            • 26. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                              pferraro

                              There are a number of problems with using org.hibernate.cache.infinispan.InfinispanRegionFactory in AS7:

                              * This implementation does not play well with modular classloading

                              * The cache manager is referenced by JNDI name, but the Infinispan cache managers in AS7 do not start unless some service depends on them (a normal jndi lookup doesn't force it to start).  Consequently, you'd have to configure the the hibernate cache-container to start eagerly.

                              * Even starting the cache manager eagerly does not ensure that the requisite cache configurations (entity, query, timestamp) are defined.  Consequently, you'd have to configure these caches to start eagerly so that their cache configurations are installed (even though these caches will never be used direcltly as they are merely templates).

                              * Even with everything starting eagerly, due to the asynchronous nature of AS7 server startup it is still possible that your application will deploy before the requisite infinispan services are started - since there are no explicit dependencies between your application and the infinispan cache manager.

                               

                              We created the org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory to explicitly address the above issues.  To use it in your application, you need to add dependencies on the "org.hibernate" and "org.infinispan" modules to your application's MANIFEST.MF.  This is documented here:

                              https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide#JPAReferenceGuide-UsingtheInfinispansecondlevelcache

                              • 27. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                                jamesviet

                                Hi Pradeep Balachandran,

                                 

                                How about your work?

                                Could you please share your DAO class?

                                 

                                I'm working on this, but seem I didn't deploy my project successfull. I need some advice from you.

                                 

                                Thanks,

                                • 28. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                                  pbalachandran

                                  After the above post highlighting the difficulties surrounding native Hibernate and Infinispan, I abandoned it, in favor of JPA. 

                                   

                                  I was able to get it to work using JPA and will be happy to share that code with you - let me know.

                                  • 29. Re: Where can I configure JBoss AS7 + Infinispan so that I can see cache statistics?
                                    jamesviet

                                    Hi Pradeep Balachandran,

                                     

                                    As I know JPA is specification and Hibernate is one such implementation of JPA.

                                    So please let me know what different between JPA and Hibernate when we use JBoss Cache as Hibernate second level cache?

                                    Do you have any special configure in standalone-full-ha , ... with IPA of JBoss 7 ?

                                     

                                    I'm a newbie with JBoss 7 and need some help from you. I use Jboss 7.1 Final, Infinispan 5, Hibernate 4.0.

                                    I'm very appreciate if you can share your code with me.

                                     

                                    Thanks,