12 Replies Latest reply on Feb 19, 2018 1:27 AM by Siva Munnaluri

    Cache Injection in Spring

    Siva Munnaluri Newbie

      I created a cache container and created cache under the cache container .

       

      if (outcome != success) of /subsystem=infinispan/cache-container=musi:read-resource

        /subsystem=infinispan/cache-container=musi:add(\

        default-cache=et-default-cache,\

        jndi-name=java:jboss/infinispan/container/musi\

        )

      end-if

       

      if (outcome != success) of /subsystem=infinispan/cache-container=musi/invalidation-cache=configuration:read-resource

        /subsystem=infinispan/cache-container=musi/invalidation-cache=configuration:add(\

        mode=ASYNC,\

        async-marshalling=true,\

        jndi-name=java:jboss/infinispan/container/musi/configuration\

        )

        /subsystem=infinispan/cache-container=musi/invalidation-cache=configuration/eviction=EVICTION:add(\

        max-entries=1000,\

        strategy=NONE\

        )

        /subsystem=infinispan/cache-container=musi/invalidation-cache=configuration/expiration=EXPIRATION:add(\

        lifespan=3600000,\

        max-idle=-1,\

        interval=-1\

        )

        /subsystem=infinispan/cache-container=musi/invalidation-cache=configuration/transaction=TRANSACTION:add(\

        mode=NONE\

        )

        /subsystem=infinispan/cache-container=musi/invalidation-cache=configuration/locking=LOCKING:add(\

        isolation=READ_COMMITTED\

        )

      end-if

       

      I am able to see the cache under cache container in jboss (Configuration -> Subsystem->Infispan->musi->configuration) and not able to see cache under runtime->subsystems->jndiview -> java/jboss->infispan). but i am not able to inject using @resource in the spring.

       

      Different ways i tried to lookup the cache .

       

      <jee:jndi-lookup id="configurationCache" jndi-name="java:jboss/infinispan/cache/musi/configuration" lookup-on-startup="true" proxy-interface="org.infinispan.Cache"/>

       

      @Resource(lookup = "java:jboss/infinispan/cache/musi/configuration")

      Cache<String,Object> cache ;

       

      Error ::

      Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: infinispan/cache/musi/configuration [Root exception is java.lang.IllegalStateException]

          Caused by: javax.naming.NameNotFoundException: infinispan/cache/musi/configuration [Root exception is java.lang.IllegalStateException]

          Caused by: java.lang.IllegalStateException"},

       

      Please suggest how to inject the cache directly in the spring and how we can see the cache under "runtime->subsystems->jndiview -> java/jboss->infispan->cache"