java.lang.IllegalArgumentException: Attribute 'nameGenerator' is of type [String], but [Class] was expected. Cause:

Spring JIRA | Sérgio Silva | 3 years ago
  1. 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:
  2. 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:
  3. 0

    When using `spring-data-couchbase` 1.4.0.BUILD-SNAPSHOT with `spring-data-commons` 1.11.0.BUILD-SNAPSHOT, an assertion failure occurs when trying to access the repositoryBaseClass. ------------- {code:title=pom.xml} .. <!-- Spring Data, Couchbase --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-couchbase</artifactId> <version>1.4.0.BUILD-SNAPSHOT</version> <exclusions> <exclusion> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>1.11.0.BUILD-SNAPSHOT</version> </dependency> ... {code} {code:title=CouchbaseConfiguration.groovy} @Configuration @EnableConfigurationProperties @ConfigurationProperties(prefix = "couchbase") @EnableCouchbaseRepositories class CouchbaseConfiguration extends AbstractCouchbaseConfiguration { List<String> hosts String bucketName String bucketPassword @Override protected List<String> bootstrapHosts() { return hosts } } {code} ---------------- On bootstrapping the application, The following exception occurs: {code} [WARNING] java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Attribute 'repositoryBaseClass' not found at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:108) at org.springframework.core.annotation.AnnotationAttributes.getClass(AnnotationAttributes.java:89) at org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.getRepositoryBaseClassName(AnnotationRepositoryConfigurationSource.java:224) at org.springframework.data.repository.config.DefaultRepositoryConfiguration.getRepositoryBaseClassName(DefaultRepositoryConfiguration.java:159) at org.springframework.data.repository.config.RepositoryBeanDefinitionBuilder.build(RepositoryBeanDefinitionBuilder.java:94) at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:128) at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:83) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:353) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:151) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) 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.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) ... {code}

    Spring JIRA | 2 years ago | A.J. Brown
    java.lang.reflect.InvocationTargetException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    When using `spring-data-couchbase` 1.4.0.BUILD-SNAPSHOT with `spring-data-commons` 1.11.0.BUILD-SNAPSHOT, an assertion failure occurs when trying to access the repositoryBaseClass. ------------- {code:title=pom.xml} .. <!-- Spring Data, Couchbase --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-couchbase</artifactId> <version>1.4.0.BUILD-SNAPSHOT</version> <exclusions> <exclusion> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>1.11.0.BUILD-SNAPSHOT</version> </dependency> ... {code} {code:title=CouchbaseConfiguration.groovy} @Configuration @EnableConfigurationProperties @ConfigurationProperties(prefix = "couchbase") @EnableCouchbaseRepositories class CouchbaseConfiguration extends AbstractCouchbaseConfiguration { List<String> hosts String bucketName String bucketPassword @Override protected List<String> bootstrapHosts() { return hosts } } {code} ---------------- On bootstrapping the application, The following exception occurs: {code} [WARNING] java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Attribute 'repositoryBaseClass' not found at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:108) at org.springframework.core.annotation.AnnotationAttributes.getClass(AnnotationAttributes.java:89) at org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.getRepositoryBaseClassName(AnnotationRepositoryConfigurationSource.java:224) at org.springframework.data.repository.config.DefaultRepositoryConfiguration.getRepositoryBaseClassName(DefaultRepositoryConfiguration.java:159) at org.springframework.data.repository.config.RepositoryBeanDefinitionBuilder.build(RepositoryBeanDefinitionBuilder.java:94) at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:128) at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:83) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:353) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:151) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) 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.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) ... {code}

    Spring JIRA | 2 years ago | A.J. Brown
    java.lang.reflect.InvocationTargetException
  6. 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:

    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 'nameGenerator' is of type [String], but [Class] was expected. Cause:

      at org.springframework.core.annotation.AnnotationAttributes.doGet()
    2. Spring Core
      AnnotationAttributes.getClass
      1. org.springframework.core.annotation.AnnotationAttributes.doGet(AnnotationAttributes.java:117)
      2. org.springframework.core.annotation.AnnotationAttributes.getClass(AnnotationAttributes.java:89)
      2 frames
    3. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:82)
      2. org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:236)
      3. org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:205)
      4. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173)
      5. org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:241)
      6. org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:205)
      7. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:182)
      8. org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:152)
      9. org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:299)
      10. org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
      11. org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
      12. org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
      13. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
      14. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      14 frames
    4. Spring MVC
      HttpServletBean.init
      1. org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
      2. org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:530)
      3. org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
      4. org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
      4 frames
    5. JavaServlet
      GenericServlet.init
      1. javax.servlet.GenericServlet.init(GenericServlet.java:160)
      1 frame
    6. Glassfish Core
      ContainerBase$StartChild.call
      1. org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
      2. org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1091)
      3. org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5033)
      4. org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5317)
      5. org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      6. org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      7. org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      7 frames
    7. Java RT
      Thread.run
      1. java.util.concurrent.FutureTask.run(FutureTask.java:262)
      2. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      3. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      4. java.lang.Thread.run(Thread.java:744)
      4 frames