com.artsquare.gallery.web.html.mockmvc.config.MockMvcMyConfig$Digitizer

Spring JIRA | Christopher Smith | 2 years ago
  1. 0

    I have the following configuration class, with a nested extension: {code} @Configuration @Import(GalleryMockMvcConfig.InMemorySecurity) @CompileStatic class MockMvcMyConfig { @Bean MyHtmlController myHtmlController(WorkImageRepository images) { new MyHtmlController(images) } @Configuration @Import(MockMvcMyConfig) @CompileStatic static class Digitizer { @Bean DigitizerClientHtmlController digitizerClientHtmlController(PersonRepository people, UploadPermissionRepository permissions, UserOperations userOps) { new DigitizerClientHtmlController(people, permissions, userOps) } } } {code} {{GalleryMockMvcConfig.InMemorySecurity}} does not include {{Digitizer}}. When trying to use this class in {{@ContextConfiguration}}, I get the following exception: {code} java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:94) at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:72) at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:170) at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:110) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:212) at org.spockframework.spring.SpringTestContextManager.prepareTestInstance(SpringTestContextManager.java:49) at org.spockframework.spring.SpringInterceptor.interceptSetupMethod(SpringInterceptor.java:42) at org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:28) at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87) at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:88) at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37) at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) at org.spockframework.runtime.extension.builtin.TestRuleInterceptor.intercept(TestRuleInterceptor.java:38) at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87) 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.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: A circular @Import has been detected: Illegal attempt by @Configuration class 'MockMvcMyConfig.Digitizer' to import class 'MockMvcMyConfig.Digitizer' as 'MockMvcMyConfig.Digitizer' is already present in the current import stack [ImportStack: [MockMvcMyConfig.Digitizer]] Offending resource: com.artsquare.gallery.web.html.mockmvc.config.MockMvcMyConfig$Digitizer at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:450) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:275) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:317) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:246) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:485) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:275) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:196) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:133) at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:60) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261) at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:68) at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:86) ... 19 more {code}

    Spring JIRA | 2 years ago | Christopher Smith
    com.artsquare.gallery.web.html.mockmvc.config.MockMvcMyConfig$Digitizer
  2. 0

    I have the following configuration class, with a nested extension: {code} @Configuration @Import(GalleryMockMvcConfig.InMemorySecurity) @CompileStatic class MockMvcMyConfig { @Bean MyHtmlController myHtmlController(WorkImageRepository images) { new MyHtmlController(images) } @Configuration @Import(MockMvcMyConfig) @CompileStatic static class Digitizer { @Bean DigitizerClientHtmlController digitizerClientHtmlController(PersonRepository people, UploadPermissionRepository permissions, UserOperations userOps) { new DigitizerClientHtmlController(people, permissions, userOps) } } } {code} {{GalleryMockMvcConfig.InMemorySecurity}} does not include {{Digitizer}}. When trying to use this class in {{@ContextConfiguration}}, I get the following exception: {code} java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:94) at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:72) at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:170) at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:110) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:212) at org.spockframework.spring.SpringTestContextManager.prepareTestInstance(SpringTestContextManager.java:49) at org.spockframework.spring.SpringInterceptor.interceptSetupMethod(SpringInterceptor.java:42) at org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:28) at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87) at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:88) at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37) at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) at org.spockframework.runtime.extension.builtin.TestRuleInterceptor.intercept(TestRuleInterceptor.java:38) at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87) 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.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: A circular @Import has been detected: Illegal attempt by @Configuration class 'MockMvcMyConfig.Digitizer' to import class 'MockMvcMyConfig.Digitizer' as 'MockMvcMyConfig.Digitizer' is already present in the current import stack [ImportStack: [MockMvcMyConfig.Digitizer]] Offending resource: com.artsquare.gallery.web.html.mockmvc.config.MockMvcMyConfig$Digitizer at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:450) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:275) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:317) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:246) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:485) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:275) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:196) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:133) at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:60) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261) at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:68) at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:86) ... 19 more {code}

    Spring JIRA | 2 years ago | Christopher Smith
    com.artsquare.gallery.web.html.mockmvc.config.MockMvcMyConfig$Digitizer

    Root Cause Analysis

    1. com.artsquare.gallery.web.html.mockmvc.config.MockMvcMyConfig$Digitizer

      No message provided

      at org.springframework.beans.factory.parsing.FailFastProblemReporter.error()
    2. Spring Beans
      FailFastProblemReporter.error
      1. org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
      1 frame
    3. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:450)
      2. org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:275)
      3. org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229)
      4. org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:317)
      5. org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:246)
      6. org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229)
      7. org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:485)
      8. org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:275)
      9. org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:229)
      10. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:196)
      11. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165)
      12. org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306)
      13. org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
      14. org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
      15. org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
      16. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
      17. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
      17 frames
    4. Spring TestContext
      DefaultCacheAwareContextLoaderDelegate.loadContext
      1. org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:133)
      2. org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:60)
      3. org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)
      4. org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)
      5. org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:68)
      6. org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:86)
      6 frames