3 Replies Latest reply on Mar 20, 2013 9:34 PM by rhauch

    Error while starting 'TestRepository' repository: Domain already registered org.infinispan

    bwallis42

      I've just ported my code to use the EAP 6 alpha release (version.jboss = 7.2.0.Alpha1-redhat-4) and am using Modeshape 3.1.3.Final. I'm getting random failures in my unit tests that produce the exception shown below. Each time I run the tests i get different tests failing and if I pick any of the failed tests and run them by themselves (in eclipse) they run fine.

       

      The error occurs on the call to repository.login() in the @Before code of the unit test.

       

       

      {code}

      javax.jcr.RepositoryException: Error while starting 'TestRepository' repository: Domain already registered org.infinispan when trying to register: type=CacheManager,name="DefaultCacheManager"

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:619)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:576)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:155)

                at au.com.infomedix.cpf4.ds.PatientRecordOperationsTest.setupSession(PatientRecordOperationsTest.java:98)

                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:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)

                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)

                at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Caused by: 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:75)

                at org.infinispan.jmx.CacheManagerJmxRegistration.updateDomain(CacheManagerJmxRegistration.java:101)

                at org.infinispan.jmx.CacheManagerJmxRegistration.buildRegistrar(CacheManagerJmxRegistration.java:95)

                at org.infinispan.jmx.AbstractJmxRegistration.registerMBeans(AbstractJmxRegistration.java:59)

                at org.infinispan.jmx.CacheManagerJmxRegistration.start(CacheManagerJmxRegistration.java:63)

                at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:705)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:300)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:268)

                at org.modeshape.jcr.LocalEnvironment.createContainer(LocalEnvironment.java:237)

                at org.modeshape.jcr.LocalEnvironment.createContainer(LocalEnvironment.java:212)

                at org.modeshape.jcr.LocalEnvironment.getCacheContainer(LocalEnvironment.java:113)

                at org.modeshape.jcr.RepositoryConfiguration.getCacheContainer(RepositoryConfiguration.java:983)

                at org.modeshape.jcr.RepositoryConfiguration.getContentCacheContainer(RepositoryConfiguration.java:973)

                at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1045)

                at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:961)

                at org.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:360)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:617)

                ... 30 more

      {code}

       

      My junit @Before and @After code is

       

      {code}

      @Before

          public void setupSession()

                            throws Exception

          {

              pro.seBean = se;

              engine     = new ModeShapeEngine();

              engine.start();

       

              RepositoryConfiguration config = RepositoryConfiguration.read("TestRepo.json");

       

              Repository repository = engine.deploy(config);

       

              pro.session = se.session = session = repository.login();

       

              NodeTypeManager nodeTypeManager = (NodeTypeManager) session.getWorkspace().getNodeTypeManager();

       

              InputStream myCndStream = pro.getClass().getClassLoader().getResourceAsStream("Cpf4JcrSchema.cnd");

              nodeTypeManager.registerNodeTypes(myCndStream, false);

       

              // Setup some default sections for the tests

              se.addSection(new SectionConfiguration("Correspondence", "Yellow", 1));

              se.addSection(new SectionConfiguration("Admissions", "Blue", 2));

       

              session.save();

          }

       

          @After

          public void teardownSession()

                               throws Exception

          {

              if(pro.session != null) {

                  pro.session.logout();

              }

              engine.shutdown(true);

          }

      {code}

       

      The TestRepo.json file contains

       

      {code}

      {

          "name" : "TestRepository"

      }

      {code}

       

      There is no appserver involved this is a simple unit test with mocks injected for any session beans used (using Mockito)