13 Replies Latest reply on Oct 14, 2017 4:00 AM by pferraro

    Wildfly 10 - Interceptor stack is not supported in simple cache

    mikedevva

      Yet another question I have about migrating from Jboss 6 to Wildfly 10.1.0.Final.

      When I enable second level cache with infinispan, I get this error:

       

      Caused by: java.lang.UnsupportedOperationException: ISPN000376: Interceptor stack is not supported in simple cache

       

      I understand that that is not supported but I can't find in my code what is causing the problem. We have a class that uses javax.interceptor.AroundInvoke and javax.interceptor.InvocationContext.  I removed the reference to that class from our ejb-jar.xml file and I still get the error. So I don't know what interceptor is causing the problem.

       

      I think the "simple cache" is coming from the ejb3 subsystem in standalone.xml where it lists the caches:

                  <caches>
                      <cache name="simple"/>
                      <cache name="distributable" passivation-store-ref="infinispan" aliases="passivating clustered"/>
                  </caches>
      

       

      I would prefer to not use a simple cache so I don't have to worry about the interceptors. But how do I do that? I can't find documentation on what I should change in this subsystem. There is only one thing referencing that simple cache. It's the stateful session-bean. I tried changing it to reference the "distributable" cache but got the same error. Either that is also a simple cache or that wasn't the one causing the error.

       

      Any help would be appreciated. I'm totally lost with this one.

        • 1. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
          pferraro

          Can you post the configuration of your Infinispan ejb cache container?

          • 2. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
            mikedevva

            Do you mean the subsystem config from standalone-full.xml? I haven't changed it at all so it's just the default. See below. If you're asking for something else can you describe more specifically what you're asking for? I'm still kind of new to all of this. Thanks.

             

                  <subsystem xmlns="urn:jboss:domain:ejb3:4.0">
                        <session-bean>
                            <stateless>
                                <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
                            </stateless>
                            <stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
                            <singleton default-access-timeout="5000"/>
                        </session-bean>
                        <mdb>
                            <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/>
                            <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
                        </mdb>
                        <pools>
                            <bean-instance-pools>
                                <strict-max-pool name="slsb-strict-max-pool" derive-size="from-worker-pools" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                                <strict-max-pool name="mdb-strict-max-pool" derive-size="from-cpu-count" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                            </bean-instance-pools>
                        </pools>
                        <caches>
                            <cache name="simple"/>
                            <cache name="distributable" passivation-store-ref="infinispan" aliases="passivating clustered"/>
                        </caches>
                        <passivation-stores>
                            <passivation-store name="infinispan" cache-container="ejb" max-size="10000"/>
                        </passivation-stores>
                        <async thread-pool-name="default"/>
                        <timer-service thread-pool-name="default" default-data-store="default-file-store">
                            <data-stores>
                                <file-data-store name="default-file-store" path="timer-service-data" relative-to="jboss.server.data.dir"/>
                            </data-stores>
                        </timer-service>
                        <remote connector-ref="http-remoting-connector" thread-pool-name="default"/>
                        <thread-pools>
                            <thread-pool name="default">
                                <max-threads count="10"/>
                                <keepalive-time time="100" unit="milliseconds"/>
                            </thread-pool>
                        </thread-pools>
                        <iiop enable-by-default="false" use-qualified-name="false"/>
                        <default-security-domain value="other"/>
                        <default-missing-method-permissions-deny-access value="true"/>
                        <log-system-exceptions value="true"/>
                    </subsystem>
            
            • 3. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
              pferraro

              It's the Infinispan subsystem configuration that I'm looking for.

              • 4. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                mikedevva

                Here's my infinispan subsystem configuration. I haven't changed that from the default either.

                 

                      <subsystem xmlns="urn:jboss:domain:infinispan:4.0">
                            <cache-container name="server" default-cache="default" module="org.wildfly.clustering.server">
                                <local-cache name="default">
                                    <transaction mode="BATCH"/>
                                </local-cache>
                            </cache-container>
                            <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
                                <local-cache name="passivation">
                                    <locking isolation="REPEATABLE_READ"/>
                                    <transaction mode="BATCH"/>
                                    <file-store passivation="true" purge="false"/>
                                </local-cache>
                                <local-cache name="persistent">
                                    <locking isolation="REPEATABLE_READ"/>
                                    <transaction mode="BATCH"/>
                                    <file-store passivation="false" purge="false"/>
                                </local-cache>
                                <local-cache name="concurrent">
                                    <file-store passivation="true" purge="false"/>
                                </local-cache>
                            </cache-container>
                            <cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">
                                <local-cache name="passivation">
                                    <locking isolation="REPEATABLE_READ"/>
                                    <transaction mode="BATCH"/>
                                    <file-store passivation="true" purge="false"/>
                                </local-cache>
                                <local-cache name="persistent">
                                    <locking isolation="REPEATABLE_READ"/>
                                    <transaction mode="BATCH"/>
                                    <file-store passivation="false" purge="false"/>
                                </local-cache>
                            </cache-container>
                            <cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">
                                <local-cache name="entity">
                                    <transaction mode="NONE"/>
                                    <!--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"/>
                            </cache-container>
                        </subsystem>
                
                • 5. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                  pferraro

                  The default configuration of your entity cache was indeed modified.  See:

                  wildfly/infinispan.xml at 10.1.0.Final · wildfly/wildfly · GitHub

                  • 6. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                    mikedevva

                    You're right. I forgot that's where I made a change to fix my previous problem. I was getting this error:

                    Caused by: java.lang.IllegalArgumentException: Currently transactional caches are not supported.

                    I found the solution to that here:

                    Using CacheConcurrencyStrategy.NONSTRICT_READ_WRITE or CacheConcurrencyStrategy.READ_WRITE with Hibernate/Infinispan in …

                     

                    Since our entities are only using NONSTRICT_READ_WRITE and READ_WRITE, it seemed reasonable to change the entity transaction mode to "NONE".  In the solution, there were no eviction or expiration elements so I commented them out. I added them back in so I have this:

                     

                              <cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">
                                    <local-cache name="entity">
                                        <transaction mode="NONE"/>
                                        <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"/>
                                </cache-container>
                    

                     

                    I still get the same error.  Does setting the transaction mode to "NONE" create a simple cache? If it does, that would explain the problem but then I would need to do something about the CacheConcurrencyStrategies in our entities.

                    • 7. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                      pferraro

                      Are you overriding any cache properties for the entity cache region?  Can you paste your persistence.xml?

                      • 8. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                        mikedevva

                        I don't think I'm overriding any cache properties. My persistence.xml is pretty basic. We were using ehcache before so there was more to it, but I commented most of that out. Here's what's left:

                         

                        <?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="IpsDb" transaction-type="JTA">
                            <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
                            <jta-data-source>java:jboss/datasources/HarmonyServerDS</jta-data-source>
                            <jar-file>../harmonyserver-model.jar</jar-file>
                            <properties>
                              <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" />
                              <property name="hibernate.id.new_generator_mappings" value="false" />     
                              <property name="hibernate.cache.use_query_cache" value="true"/>
                              <property name="hibernate.cache.use_second_level_cache" value="true"/>
                            </properties>
                          </persistence-unit>
                        </persistence>
                        
                        • 9. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                          pferraro

                          Hmm.  The simple cache optimization in Infinispan is auto-enabled when the cache is local, non-transactional, and does not contain a cache store.  This is meant to allow the cache to operate without an interceptor stack.  However, somehow, an interceptor stack is getting installed anyway.  Can you paste the full stack trace containing the UnsupportedOperationException?

                          • 10. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                            mikedevva

                            Here's the full stack trace:

                             

                            2017-10-06 14:56:36,221 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 19) MSC000001: Failed to start service jboss.persistenceunit."harmonyserver.sar#IpsDb": org.jboss.msc.service.StartException in service jboss.persistenceunit."harmonyserver.sar#IpsDb": javax.persistence.PersistenceException: [PersistenceUnit: IpsDb] Unable to build Hibernate SessionFactory

                                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:179)

                                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:121)

                                at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)

                                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:193)

                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

                                at java.lang.Thread.run(Thread.java:748)

                                at org.jboss.threads.JBossThread.run(JBossThread.java:320)

                            Caused by: javax.persistence.PersistenceException: [PersistenceUnit: IpsDb] Unable to build Hibernate SessionFactory

                                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)

                                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)

                                at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)

                                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:161)

                                ... 7 more

                            Caused by: java.lang.UnsupportedOperationException: ISPN000376: Interceptor stack is not supported in simple cache

                                at org.infinispan.cache.impl.SimpleCacheImpl.removeInterceptor(SimpleCacheImpl.java:952)

                                at org.infinispan.cache.impl.AbstractDelegatingAdvancedCache.removeInterceptor(AbstractDelegatingAdvancedCache.java:85)

                                at org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion.prepareForVersionedEntries(BaseTransactionalDataRegion.java:154)

                                at org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion.createAccessDelegate(BaseTransactionalDataRegion.java:122)

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

                                at org.hibernate.internal.SessionFactoryImpl.determineEntityRegionAccessStrategy(SessionFactoryImpl.java:624)

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

                                at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)

                                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)

                                ... 9 more

                            • 11. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                              pferraro

                              Here's the problem:

                              hibernate-orm/BaseTransactionalDataRegion.java at 5.0 · hibernate/hibernate-orm · GitHub

                              The region factory implementation assumes an interceptor stack exists in order to support NON_STRICT_READ_WRITE cache access.  Until this is fixed, you'll either need to use a transactional cache (disabling the simple cache optimization) or switch these entities to use READ_WRITE cache access (allowing the use of the simple cache optimization).

                              • 12. Re: Wildfly 10 - Interceptor stack is not supported in simple cache
                                mikedevva

                                If I switch all of the entities using NONSTRICT_READ_WRITE to READ_WRITE, I don't get any errors. We will just need to look to make sure this is acceptable. Hopefully there will not be a performance hit.