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

Spring JIRA | Maciej Drozdzowski | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  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 | 3 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 | 3 years ago | Maciej Drozdzowski
    java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected. Cause:

    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