Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10580

ClassCastException on meta @Components with not Spring value

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2.3
    • Fix Version/s: 3.2.4, 4.0 M2
    • Component/s: Core:DI
    • Labels:

      Description

      New in 3.2.3.RELEASE there is a bug in how Spring determines bean names from annotations. The annotation that is causing the issue looks like:

      @Retention(RetentionPolicy.RUNTIME)
      @Target(ElementType.TYPE)
      @Component
      public @interface ConfigurationAnalyzer {
      
          ConfigurationType[] value();
      }
      

      Based on the stack trace generated by the bug, it's pretty straight forward where things are going wrong.

      java.lang.ClassCastException: [L<REDACTED>.ConfigurationType; cannot be cast to java.lang.String
      	at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:91)
      	at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:69)
      	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:246)
      	at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:123)
      	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:191)
      	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:165)
      	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:140)
      	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:282)
      	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
      	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
      <REDACTED>
      

        Attachments

          Activity

            People

            • Assignee:
              pwebb Phil Webb
              Reporter:
              nebhale nebhale
              Last updater:
              Spring Issuemaster
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                26 weeks, 2 days ago