11 Replies Latest reply on Aug 16, 2011 6:46 PM by scottg

    Two wars using second level cache

    scottg

      I'm trying to deploy two webapps, both with infinispan configured as the hibernate second level cache, but on startup I recieve the following exception.

       

      Caused by: org.infinispan.config.ConfigurationException: Detected interceptor of type [org.hibernate.cache.infinispan.impl.ClassLoaderAwareCache$ClassLoaderAwareCommandInterceptor] being added to the interceptor chain more than once!

       

      The relevant configuration in both persistence.xml files is is this.

       

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

                       value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"/>

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

                       value="java:jboss/infinispan/hibernate"/>

      <property name="hibernate.transaction.manager_lookup_class"

                       value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

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

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

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

       

      Any ideas?

        • 1. Re: Two wars using second level cache
          smarlow

          Could you include the full exception stack trace? 

          • 2. Re: Two wars using second level cache
            smarlow

            I was able to recreate with a unit test.  Exception call stack is shown here http://pastebin.com/gi4VxRgg

            • 3. Re: Two wars using second level cache
              smarlow

              Scott,

               

              Can you create a jira for this issue?  That way, you can get credit for finding this bug. 

               

              Thanks for reporting it!

               

              Scott

              • 4. Re: Two wars using second level cache
                smarlow

                Here is a quick hack.  Please still create a bug report in jira (https://issues.jboss.org/browse/AS7) for this.  Or let me know if you won't and I will.

                 

                Add a unique cache manager in each application:

                 

                App1:

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

                                 value="java:jboss/infinispan/hibernate_App1"/>

                 

                App2:

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

                                 value="java:jboss/infinispan/hibernate_App2"/>

                 

                The default cache manager name "java:jboss/infinispan/hibernate" is already configured in AS/standalone/configuration/standalone.xml.  You need to add new caches for "java:jboss/infinispan/hibernate_App1" and "java:jboss/infinispan/hibernate_App2"

                 

                Change standalone.xml from:

                 

                {quote}

                <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate">

                <cache-container name="hibernate" default-cache="local-query">

                <local-cache name="entity">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="local-query">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="timestamps">

                <eviction strategy="NONE"/>

                </local-cache>

                </cache-container>

                </subsystem>

                {quote}

                 

                Change to:

                {quote}

                <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate">

                <cache-container name="hibernate" default-cache="local-query">

                <local-cache name="entity">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="local-query">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="timestamps">

                <eviction strategy="NONE"/>

                </local-cache>

                </cache-container>

                 

                <cache-container name="hibernate_App1" default-cache="local-query">

                <local-cache name="entity">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="local-query">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="timestamps">

                <eviction strategy="NONE"/>

                </local-cache>

                </cache-container>

                 

                <cache-container name="hibernate_App2" default-cache="local-query">

                <local-cache name="entity">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="local-query">

                <eviction strategy="LRU" max-entries="10000"/>

                <expiration max-idle="100000"/>

                </local-cache>

                <local-cache name="timestamps">

                <eviction strategy="NONE"/>

                </local-cache>

                </cache-container>

                </subsystem>

                {quote}

                • 5. Re: Two wars using second level cache
                  scottg

                  I have been trying a to add a bug report, but when I try to log into Jira I get internal server error.

                  • 6. Re: Two wars using second level cache
                    smarlow

                    I just tried to login and was able to.  Perhaps if you tried again, it might work better now.

                    • 7. Re: Two wars using second level cache
                      scottg

                      Still no go, I sent a support request yesterday but have not heard anything. Perhaps you should go ahead and set up the issue.

                      • 8. Re: Two wars using second level cache
                        smarlow

                        I created jira AS7-1544 for this issue.  Thanks again for reporting it.  Let me know if the above workaround helps you.

                        • 9. Re: Two wars using second level cache
                          smarlow

                          Actually, a better workaround (set PU property "hibernate.cache.region_prefix" to a unique value) is described in the jira.  The above workaround is not as good.

                          • 10. Re: Two wars using second level cache
                            smarlow

                            Fixed for AS 7.0.1! 

                            • 11. Re: Two wars using second level cache
                              scottg

                              Very quick turn around. Thank you.