Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-4971

CDI uses default EmbeddedCacheManager producer from infinispan-cdi.jar instead of custom one

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • 7.0.0.CR1, 7.0.0.CR2, 7.0.0.Final
    • CDI
    • None

    Description

      Custom producer has allowDuplicateDomains set to true look following code

      public class EmbeddedCacheManagerProducer {
         /**
          * Produces the default embedded cache manager.
          *
          * @param providedDefaultEmbeddedCacheManager the provided default embedded cache manager.
          * @param defaultConfiguration the default configuration produced by the {@link EmbeddedCacheManagerProducer}.
          * @return the default embedded cache manager used by the application.
          */
         @Produces
         @ApplicationScoped
         public EmbeddedCacheManager getDefaultEmbeddedCacheManager(@OverrideDefault Instance<EmbeddedCacheManager> providedDefaultEmbeddedCacheManager, Configuration defaultConfiguration) {
            GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build();
      
            ConfigurationBuilder builder = new ConfigurationBuilder();
            builder.read(defaultConfiguration);
      
            return new DefaultCacheManager(globalConfiguration, builder.build());
         }
      
         /**
          * Stops the default embedded cache manager when the corresponding instance is released.
          *
          * @param defaultEmbeddedCacheManager the default embedded cache manager.
          */
         private void stopCacheManager(@Disposes EmbeddedCacheManager defaultEmbeddedCacheManager) {
            defaultEmbeddedCacheManager.stop();
         }
      }
      

      And default ones from infinispan-cdi.jar is

      public class DefaultEmbeddedCacheManagerProducer {
      
         private static final Log log = LogFactory.getLog(DefaultEmbeddedCacheManagerProducer.class, Log.class);
      
         /**
          * Produces the default embedded cache manager.
          *
          * @param providedDefaultEmbeddedCacheManager the provided default embedded cache manager.
          * @param defaultConfiguration the default configuration produced by the {@link DefaultEmbeddedCacheConfigurationProducer}.
          * @return the default embedded cache manager used by the application.
          */
         @Produces
         @ApplicationScoped
         @DefaultBean(EmbeddedCacheManager.class)
         public EmbeddedCacheManager getDefaultEmbeddedCacheManager(@OverrideDefault Instance<EmbeddedCacheManager> providedDefaultEmbeddedCacheManager, Configuration defaultConfiguration) {
            if (!providedDefaultEmbeddedCacheManager.isUnsatisfied()) {
               log.tracef("Default embedded cache manager overridden by '%s'", providedDefaultEmbeddedCacheManager);
               return providedDefaultEmbeddedCacheManager.get();
            }
            return new DefaultCacheManager(defaultConfiguration);
         }
      
         /**
          * Stops the default embedded cache manager when the corresponding instance is released.
          *
          * @param defaultEmbeddedCacheManager the default embedded cache manager.
          */
         private void stopCacheManager(@Disposes EmbeddedCacheManager defaultEmbeddedCacheManager) {
            defaultEmbeddedCacheManager.stop();
         }
      }
      

      When tests are deployed to APP server then following ERROR occurs
      10:19:58,494 ERROR [org.infinispan.jmx.JmxUtil] (http-localhost.localdomain/127.0.0.1:8080-1) ISPN000034: There's already an cache manager instance registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element
      10:19:58,526 ERROR [org.infinispan.jmx.JmxUtil] (http-localhost.localdomain/127.0.0.1:8080-1) ISPN000034: There's already an cache manager instance registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element
      10:19:58,598 ERROR [org.infinispan.jmx.JmxUtil] (http-localhost.localdomain/127.0.0.1:8080-1) ISPN000034: There's already an cache manager instance registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element

      What means that out custom producer is sometimes not used and does not override default produced EmbeddedCacheManager

      Attachments

        Issue Links

          Activity

            People

              slaskawi@redhat.com Sebastian Ɓaskawiec (Inactive)
              vchepeli_jira Vitalii Chepeliuk (Inactive)
              Vitalii Chepeliuk Vitalii Chepeliuk (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: