java.lang.IllegalStateException: Cannot load configuration class: org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature

Spring JIRA | Chris Beams | 6 years ago
  1. 0

    Example: processing the following nested {{private}} class {code} @Configuration private static class MvcDefaultServletHandlerFeature { @SuppressWarnings("unused") @Feature public MvcDefaultServletHandler defaultServletHandler() { return new MvcDefaultServletHandler("foo"); } } {code} results in the following stack trace: {code} java.lang.IllegalStateException: Cannot load configuration class: org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:363) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:197) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:170) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437) at org.springframework.web.servlet.config.MvcDefaultServletHandlerTests.testDefaultServletHandler(MvcDefaultServletHandlerTests.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) 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: java.lang.IllegalArgumentException: No visible constructors in class org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature at net.sf.cglib.proxy.Enhancer.filterConstructors(Enhancer.java:531) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:448) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:127) at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:97) at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:355) ... 27 more {code} This is because CGLIB subclassing is required even for {{@Configuration}} classes that declare no {{@Bean}} methods. The user is forced to make the class non-{{private}} to work around this.

    Spring JIRA | 6 years ago | Chris Beams
    java.lang.IllegalStateException: Cannot load configuration class: org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature
  2. 0

    Example: processing the following nested {{private}} class {code} @Configuration private static class MvcDefaultServletHandlerFeature { @SuppressWarnings("unused") @Feature public MvcDefaultServletHandler defaultServletHandler() { return new MvcDefaultServletHandler("foo"); } } {code} results in the following stack trace: {code} java.lang.IllegalStateException: Cannot load configuration class: org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:363) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:197) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:170) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437) at org.springframework.web.servlet.config.MvcDefaultServletHandlerTests.testDefaultServletHandler(MvcDefaultServletHandlerTests.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) 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: java.lang.IllegalArgumentException: No visible constructors in class org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature at net.sf.cglib.proxy.Enhancer.filterConstructors(Enhancer.java:531) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:448) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:127) at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:97) at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:355) ... 27 more {code} This is because CGLIB subclassing is required even for {{@Configuration}} classes that declare no {{@Bean}} methods. The user is forced to make the class non-{{private}} to work around this.

    Spring JIRA | 6 years ago | Chris Beams
    java.lang.IllegalStateException: Cannot load configuration class: org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature
  3. 0

    Can not remove the modifier of final class

    Stack Overflow | 4 years ago | xuongrong
    java.lang.IllegalArgumentException: Cannot subclass final class class mediatheque.document.Livre
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error mocking final class with static method with JUnit 4.x and EasyMock

    Google Groups | 6 years ago | Kartik Kumar
    java.lang.IllegalArgumentException: Cannot subclass final class class com.teracent.partnerfetch.common.Partner*
  6. 0

    Redchilliplus's Blog | little extra..

    wordpress.com | 1 year ago
    java.lang.IllegalArgumentException: Cannot subclass final class class com.unittest.FinalClass

    9 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      No visible constructors in class org.springframework.web.servlet.config.MvcDefaultServletHandlerTests$MvcDefaultServletHandlerFeature

      at net.sf.cglib.proxy.Enhancer.filterConstructors()
    2. IDEA
      Enhancer.generateClass
      1. net.sf.cglib.proxy.Enhancer.filterConstructors(Enhancer.java:531)
      2. net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:448)
      2 frames
    3. Code Generation Library
      AbstractClassGenerator.create
      1. net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
      2. net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      2 frames
    4. IDEA
      Enhancer.createClass
      1. net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
      2. net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
      2 frames
    5. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:127)
      2. org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:97)
      3. org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:355)
      4. org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:197)
      5. org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:170)
      6. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604)
      7. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437)
      7 frames
    6. Spring MVC
      MvcDefaultServletHandlerTests.testDefaultServletHandler
      1. org.springframework.web.servlet.config.MvcDefaultServletHandlerTests.testDefaultServletHandler(MvcDefaultServletHandlerTests.java:40)
      1 frame
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    8. JUnit
      ParentRunner.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      5. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      7. org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      8. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      9. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      10. org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      11. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      12. org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      12 frames
    9. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
      1 frame
    10. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      5 frames