2 Replies Latest reply on Sep 11, 2014 3:30 AM by Sebastian Łaskawiec

    JCache bug? ISPN021015: Cache xyz-cache already registered

    Elias Ross Master

      Infinispan 6.0.2.Final release.

       

      This exception is thrown, but I don't know why:

       

      INFO  22-07 13:46:59,880 (org.infinispan.factories.GlobalComponentRegistry) - ISPN000128: Infinispan version: Infinispan 'Infinium' 6.0.2.Final
      DEBUG 22-07 13:47:00,039 (org.infinispan.interceptors.InterceptorChain) - Interceptor chain size: 7
      DEBUG 22-07 13:47:00,039 (org.infinispan.interceptors.InterceptorChain) - Interceptor chain is:
              >> org.infinispan.interceptors.InvocationContextInterceptor
              >> org.infinispan.interceptors.CacheMgmtInterceptor
              >> org.infinispan.interceptors.MarshalledValueInterceptor
              >> org.infinispan.interceptors.NotificationInterceptor
              >> org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor
              >> org.infinispan.interceptors.EntryWrappingInterceptor
              >> org.infinispan.interceptors.CallInterceptor
      DEBUG 22-07 13:47:00,044 (org.infinispan.jmx.JmxUtil) - Object name org.infinispan:type=Cache,name="cert-cache(local)",manager="uri=org.infinispan.jcache.JCachingProvider/classlo
      ader=sun.misc.Launcher$AppClassLoader@58e862c/provider=org.infinispan.jcache.JCachingProvider@39c5333",component=Cache already registered
      INFO  22-07 13:47:00,044 (org.infinispan.jmx.CacheJmxRegistration) - ISPN000031: MBeans were successfully registered to the platform MBean server.
      DEBUG 22-07 13:47:00,045 (org.infinispan.CacheImpl) - Started cache cert-cache on null
      DEBUG 22-07 13:47:00,053 (MyMDB) - failed, attempting to retry
      javax.cache.CacheException: ISPN021015: Cache cert-cache already registered with configuration javax.cache.configuration.MutableConfiguration@89febc62, and can not be registered
      again with a new given configuration javax.cache.configuration.MutableConfiguration@89febc62
              at org.infinispan.jcache.JCacheManager.createCache(JCacheManager.java:194)
              at org.infinispan.jcache.annotation.DefaultCacheResolver.resolveCache(DefaultCacheResolver.java:53)
              at org.infinispan.jcache.annotation.DefaultCacheResolver$Proxy$_$$_WeldClientProxy.resolveCache(Unknown Source)
              at org.infinispan.jcache.annotation.AbstractCacheResultInterceptor.cacheResult(AbstractCacheResultInterceptor.java:56)
              at org.infinispan.jcache.annotation.CacheResultInterceptor.cacheResult(CacheResultInterceptor.java:47)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:74)
              at org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNext(AbstractInterceptionChain.java:116)
              at org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNextInterceptor(AbstractInterceptionChain.java:94)
              at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:43)
              at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:36)
              at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:51)
              at ...MockCertificateBean$Proxy$_$$_WeldSubclass.findCertificate(Unknown Source)
              at ...MockCertificateBean$Proxy$_$$_WeldClientProxy.findCertificate(Unknown Souzxxrce)
      
      

      I'm using the JCache API, like so:

       

      /**
      * Produces the configuration for Infinispan.
      */
      public class CertificateCacheConfig {
      
          static final String name = "cert-cache";
      
          @ConfigureCache(name)
          @Produces
          public Configuration cacheConfiguration() {
              return new ConfigurationBuilder().eviction()
                      .strategy(EvictionStrategy.LRU).maxEntries(100).build();
          }
      
      }
      
      

       

      The method:

       

      @Specializes
      @ApplicationScoped
      public class MockCertificateBean extends CertificateBean {
      
          @Override
          @CacheResult(cacheName=CertificateCacheConfig.name)
          public Certificate findCertificate(String passTypeId) {
      ...
          }
      }
      
      
      

       

      I'm wondering what's going on, as it seems mostly harmless but I don't want the exception thrown every time the method is called.

       

      Could it be because of multi-threading issues or a bug? I'm guessing in a context of an MDB this can happen as many threads are probably calling DefaultCacheResolver.resolveCache and there is no locking in that class.