java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause:

Spring JIRA | Maciej Drozdzowski | 2 years ago
  1. 0

    If @ComponentScan is used as a meta annotation and filters are attributes that can be overriden via the target annotation, the following happens: {noformat} java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause: at org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:117) at org.springframework.core.annotation.AnnotationAttributes.getAnnotationArray(AnnotationAttributes.java:101) at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:103) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:249) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:155) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:305) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) 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:609) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:606) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) {noformat} When the filters are uses like so, in the meta-annotation, it works well: {code:java} @ComponentScan( excludeFilters = { @ComponentScan.Filter(type = FilterType.ANNOTATION, value = TestConfiguration.class) } ) @Import(PostProcessors.class) @EnableWebMvc @Configuration @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface WebContextConfiguration { } {code} This however, breaks: {code:java} @ComponentScan @Import(PostProcessors.class) @EnableWebMvc @Configuration @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface WebContextConfiguration { Filter[] excludeFilters() default {}; } @WebContextConfiguration( excludeFilters = { @ComponentScan.Filter(type = FilterType.ANNOTATION, value = TestConfiguration.class) } ) public class Config {} {code}

    Spring JIRA | 2 years ago | Maciej Drozdzowski
    java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause:
  2. 0

    If @ComponentScan is used as a meta annotation and filters are attributes that can be overriden via the target annotation, the following happens: {noformat} java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause: at org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:117) at org.springframework.core.annotation.AnnotationAttributes.getAnnotationArray(AnnotationAttributes.java:101) at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:103) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:249) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:155) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:305) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) 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:609) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:606) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) {noformat} When the filters are uses like so, in the meta-annotation, it works well: {code:java} @ComponentScan( excludeFilters = { @ComponentScan.Filter(type = FilterType.ANNOTATION, value = TestConfiguration.class) } ) @Import(PostProcessors.class) @EnableWebMvc @Configuration @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface WebContextConfiguration { } {code} This however, breaks: {code:java} @ComponentScan @Import(PostProcessors.class) @EnableWebMvc @Configuration @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface WebContextConfiguration { Filter[] excludeFilters() default {}; } @WebContextConfiguration( excludeFilters = { @ComponentScan.Filter(type = FilterType.ANNOTATION, value = TestConfiguration.class) } ) public class Config {} {code}

    Spring JIRA | 2 years ago | Maciej Drozdzowski
    java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause:
  3. 0

    What's wrong with RabbitMQ in Spring Boot

    Stack Overflow | 2 years ago
    java.lang.IllegalArgumentException: Attribute 'exclude' is of type [Class[]], but [String[]] was expected. Cause:
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Not able to run the Complete part

    GitHub | 2 years ago | sohambannerjee8
    java.lang.IllegalArgumentException: Attribute 'exclude' is of type [Class[]], but [String[]] was expected. Cause:
  6. 0

    I'm trying to create a _composed annotation_ which uses {{@Configuration}} and {{@ComponentScan}} as meta-annotations. {code} @Configuration @ComponentScan @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface BennuSpringModule { String[] basePackages() default {}; String[] bundles() default {}; } {code} The problem appears in {{ConfigurationClassPostProcessor}}: {noformat} java.lang.IllegalArgumentException: Attribute 'nameGenerator' is of type [String], but [Class] was expected. Cause: at org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:117) at org.springframework.core.annotation.AnnotationAttributes.getClass(AnnotationAttributes.java:89) at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:82) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:236) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:205) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:241) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:205) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:182) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:152) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:299) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) 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:609) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:530) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:160) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1091) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5033) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5317) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) {noformat} The meta-annotation is being processed with {{classValuesAsString}} set to {{true}} which breaks the look-up for Class Type. See [AnnotationAttributesReadingVisitor|https://github.com/spring-projects/spring-framework/blob/161819f1417579c915751a6ef1fa7699963574fb/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java#L282] for details.

    Spring JIRA | 3 years ago | Sérgio Silva
    java.lang.IllegalArgumentException: Attribute 'nameGenerator' is of type [String], but [Class] was expected. Cause:

    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

      Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause:

      at org.springframework.core.annotation.AnnotationAttributes.doGet()
    2. Spring Core
      AnnotationAttributes.getAnnotationArray
      1. org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:117)
      2. org.springframework.core.annotation.AnnotationAttributes.getAnnotationArray(AnnotationAttributes.java:101)
      2 frames
    3. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:103)
      2. org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:249)
      3. org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218)
      4. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)
      5. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:155)
      6. org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:305)
      7. org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
      8. org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
      9. org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
      10. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
      11. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      11 frames
    4. Spring
      ContextLoaderListener.contextInitialized
      1. org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
      2. org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      3. org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
      3 frames
    5. Glassfish Core
      Catalina.start
      1. org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
      2. org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
      3. org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
      4. org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
      5. org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
      6. org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
      7. org.apache.catalina.core.StandardService.start(StandardService.java:525)
      8. org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
      9. org.apache.catalina.startup.Catalina.start(Catalina.java:595)
      9 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:606)
      4 frames
    7. Springloaded
      ReflectiveInterceptor.jlrMethodInvoke
      1. org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
      1 frame
    8. Glassfish Core
      Bootstrap.main
      1. org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      2. org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
      2 frames