0 Replies Latest reply on Jul 19, 2019 6:36 PM by nimo22

    how to inject "javax.cache.CacheManager" by Wildfly

    nimo22

      In wildfly 17, I can use the following code to inject the cache (provided by infinispan):

       

      // no need for web.xml resource-ref
      @Resource(lookup="java:jboss/infinispan/container/my-cache")
      private EmbeddedCacheManager cacheManager;

       

      I have included the official jcache-lib (and not the infinispan-jcache) within my pom.xml:

       

          <!--  include javax.cache-api -->

          <!-- no need for infinispan-jcache as this is already provided by wildfly server? -->

          <dependency>

              <groupId>javax.cache</groupId>

              <artifactId>cache-api</artifactId>

              <version>${version.jcache}</version>

          </dependency>

       

       

      All works.

       

      However, how can I inject the javax.cache.CacheManager by Wildfly Container? The following injection does not work:

       

      @Resource(lookup="java:jboss/infinispan/container/my-cache")
      private javax.cache.CacheManager cacheManager;

       

      Is there a way to get the javax.cache.CacheManager by EmbeddedCacheManager?