3 Replies Latest reply on Nov 7, 2012 2:07 AM by true_mykola

    "Domain already registered" after EAR is redeployed

    true_mykola

      Hi!

      I've just started using Infinispan and immediately fell in trouble: i can't create DefaultCacheManager after application is redeployed without restarting web server. I get this exception:

      org.infinispan.jmx.JmxDomainConflictException: Domain already registered org.infinispan when trying to register: type=CacheManager,name="DefaultCacheManager"
          at org.infinispan.jmx.JmxUtil.buildJmxDomain(JmxUtil.java:73)
          at org.infinispan.jmx.CacheManagerJmxRegistration.updateDomain(CacheManagerJmxRegistration.java:100)
          at org.infinispan.jmx.CacheManagerJmxRegistration.buildRegistrar(CacheManagerJmxRegistration.java:94)
          at org.infinispan.jmx.AbstractJmxRegistration.registerMBeans(AbstractJmxRegistration.java:59)
          at org.infinispan.jmx.CacheManagerJmxRegistration.start(CacheManagerJmxRegistration.java:62)
          at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:709)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:383)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:356)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:342)
      

      At first start everything works fine.

      This is how i create CacheManager (SystemException is our internal class):

      public class CacheManager {
          private static DefaultCacheManager manager;
          
          public static DefaultCacheManager getCacheManager() throws SystemException {
              if (manager == null) {
                  try {
                      manager = new DefaultCacheManager(FacesContext.getCurrentInstance()
                              .getExternalContext().getResourceAsStream("/WEB-INF/infinispan.xml"));
                  } catch (IOException e) {
                      throw new SystemException(e);
                  }
              }
              return manager;
          }
      }
      

      infinispan.xml contains just this:

      <infinispan />
      

      What should i do to get rid of this exception? If this cache somehow is still running after application is redeployed (without restarting web server) how can i use it instead of creating new one?

      Web server is Weblogic 10.3.0. JSF 1.2.

        • 1. Re: "Domain already registered" after EAR is redeployed
          mircea.markus

          You have two infinispan instances trying to bind to the same jmx domain. You can either set up a different domain name for your second instance, or let ifninispan generate one for your: see allowDuplicateDomains in the user manual.

          • 2. Re: "Domain already registered" after EAR is redeployed
            true_mykola

            But why are there two instances when i start only one? can i kill the second or may be i can somehow use it onstead of creating new one? As i said when i start the application server everything works fine, the problem occurs when i redeploy EAR without restarting application server, so the second infinspan instance is definitely the one that was launched when application was started for the very first time after Weblogic had started.Hence i suppose that i should be able either to kill it or use it but i don't know how.

            • 3. Re: "Domain already registered" after EAR is redeployed
              true_mykola

              Well, it seems like i've solved it. The solution is simple and was taken from documentation (it's strange that no one told me to rtfm ):

              "When the system shuts down, it should call stop() on the CacheManager. This will ensure all caches within its scope are properly stopped as well. "

              So i call stop() from contextDestroyed() of our implementation of ServletContextListener and everything works fine.