1 2 Previous Next 19 Replies Latest reply on Jul 23, 2018 3:30 AM by Jure Vizjak Go to original post
      • 15. Re: Wildfly 12 Cache migration error
        Paul Ferraro Master

        The code you supplied above was never 100% reliable - it would always be subject to a race condition between the installation of the cache configuration and your application - thus isn't a regression.

         

        Additionally injecting the cache configuration will certainly correct your issue, but I seems to me that injecting the cache directly is even simpler.

        e.g.

         

        @Resource(lookup = "java:jboss/infinispan/cache/Foo/Bar")
        private Cache<string, integer=""> cache;

         

        EDIT: Ugh - this code formatting widget is awful.

        The above should read:

        private Cache<String, Integer> cache;

        1 of 1 people found this helpful
        • 16. Re: Wildfly 12 Cache migration error
          Benjamin Börngen-Schmidt Newbie

          Thank you for clearing this up! I wanted to post this, so if anyone else runs into the same problem knows that it ain't a regression, but was bad before anyways.

           

          What you suggessted is the way I refactored the application.

          • 17. Re: Wildfly 12 Cache migration error
            Jure Vizjak Newbie

            The solutions written so far just don't work for me. I've migrated Wildfly 9 to 13 and got stuck. I've tried all sorts of combinations from the answers above, but nothing works. I'm still stuck with "javax.ejb.EJBException: org.infinispan.commons.CacheConfigurationException: ISPN000436: Cache 'default' has been requested, but no cache configuration exists with that name and no default cache has been set for this container"

            I've tried the resource-ref suggestion, but when using it with the @Resource annotation

             

            @Resource(lookup = "infinispan/replicatedCache"))

             

            , the system just fails with error message

                "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
                Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
                Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: WFLYWELD0049: Error injecting resource into CDI managed bean. Can't find a resource named infinispan/replicatedCache defined on private org.infinispan.manager.CacheContainer com.toshl.api.infinispan.InfinispanManager.replicatedCacheContainer
                Caused by: java.lang.IllegalArgumentException: WFLYWELD0049: Error injecting resource into CDI managed bean. Can't find a resource named infinispan/replicatedCache defined on private org.infinispan.manager.CacheContainer com.toshl.api.infinispan.InfinispanManager.replicatedCacheContainer
                Caused by: javax.naming.NameNotFoundException: infinispan/replicatedCache -- service jboss.naming.context.java.infinispan.replicatedCache"}

             

            I've tried putting the resource-ref element into web.xml and jboss-web.xml without success.

             

                <resource-ref>

                    <res-ref-name>infinispan/localCache</res-ref-name>

                    <jndi-name>java:jboss/infinispan/container/localCache</jndi-name>

                </resource-ref>

                <resource-ref>

                    <res-ref-name>infinispan/replicatedCache</res-ref-name>

                    <jndi-name>java:jboss/infinispan/container/replicatedCache</jndi-name>

                </resource-ref>

             

            From the Wildfly console I can see that the containers are registered in the JNDI tree (localCache and replicatedCache)

            VisualVM also list the containers, but caches are nowhere to see.

            This is subsystem's configuration:

             

                    <subsystem xmlns="urn:jboss:domain:infinispan:6.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.infinispan.hibernate-cache">

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

                                <object-memory size="10000"/>

                                <expiration max-idle="100000"/>

                            </local-cache>

                            <local-cache name="entity">

                                <transaction mode="NON_XA"/>

                                <object-memory size="10000"/>

                                <expiration max-idle="100000"/>

                            </local-cache>

                            <local-cache name="timestamps"/>

                        </cache-container>

                        <cache-container name="localCache" default-cache="default">

                            <local-cache name="default">

                                <transaction mode="NONE"/>

                                <object-memory size="10000"/>

                            </local-cache>

                        </cache-container>

                        <cache-container name="replicatedCache" default-cache="default">

                            <local-cache name="default">

                                <transaction mode="NONE"/>

                                <object-memory size="10000"/>

                            </local-cache>

                        </cache-container>

                    </subsystem>

              

            Help really appreciated.

            • 18. Re: Wildfly 12 Cache migration error
              Paul Ferraro Master

              jurevi  wrote:

              I've tried putting the resource-ref element into web.xml and jboss-web.xml without success.

               

                  <resource-ref>

                      <res-ref-name>infinispan/localCache</res-ref-name>

                      <jndi-name>java:jboss/infinispan/container/localCache</jndi-name>

                  </resource-ref>

                  <resource-ref>

                      <res-ref-name>infinispan/replicatedCache</res-ref-name>

                      <jndi-name>java:jboss/infinispan/container/replicatedCache</jndi-name>

                  </resource-ref>

              This does not conform to the EE schema:

              http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html#7

               

              Try this instead:

               

                  <resource-ref>

                      <res-ref-name>infinispan/localCache</res-ref-name>

                      <lookup-name>java:jboss/infinispan/cache/localCache/default</lookup-name>

                  </resource-ref>

                  <resource-ref>

                      <res-ref-name>infinispan/replicatedCache</res-ref-name>

                      <lookup-name>java:jboss/infinispan/cache/replicatedCache/default</lookup-name>

                  </resource-ref>

               

              You should now be able to inject your cache via:

               

              @Resource(name = "infinispan/localCache")

              private Cache<K, V> localCache;

               

              @Resource(name = "infinispan/replicatedCache")

              private Cache<K, V> replicatedCache;

              1 of 1 people found this helpful
              • 19. Re: Wildfly 12 Cache migration error
                Jure Vizjak Newbie

                It worked, thanks a lot!

                I believe I've never made it work because I was always trying to inject the resource with

                @Resource(lookup = "infinispan/replicatedCache")
                
                

                instead of

                @Resource(name = "infinispan/replicatedCache")
                1 2 Previous Next