java.lang.IllegalAccessException: Class org.springframework.core.annotation.AnnotationUtils can not access a member of class com.linkedin.restli.server.annotations.RestMethod$ToResourceMethod with modifiers "public abstract"

Spring JIRA | Keli Hlodversson | 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 a member of a component candidate is annotated with an attribute, that again is annotated with a privately scoped meta-attribute containing values, the scanning will fail with an Illegal state exception caused by an IllegalAccessException caught in org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes. An example where this happens if one uses the rest.li framework in connection with spring: {code:title=RestMethod.java|borderStyle=solid} public class RestMethod { /** * This annotation defines mapping of RestMethod annotations to {@link com.linkedin.restli.common.ResourceMethod} */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) private static @interface ToResourceMethod { ResourceMethod value(); } ... @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @ToResourceMethod(ResourceMethod.GET) public @interface Get { } ... } {code} {code:title=MyComponent.java|borderStyle=solid} @Component .... public class MyComponent extends SomeRestliBaseClass { @RestMethods.Get // Adding this attribute causes the stack trace below public ARecord get (String id) { .... } } {code} {noformat} org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file […]; nested exception is java.lang.IllegalStateException: Could not obtain annotation attribute values at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) … Caused by: java.lang.IllegalStateException: Could not obtain annotation attribute values at org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:432) at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.registerMetaAnnotations(AnnotationAttributesReadingVisitor.java:250) at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.doVisitEnd(AnnotationAttributesReadingVisitor.java:241) at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:167) at org.springframework.asm.ClassReader.a(Unknown Source) at org.springframework.asm.ClassReader.accept(Unknown Source) at org.springframework.asm.ClassReader.accept(Unknown Source) at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) … Caused by: java.lang.IllegalAccessException: Class org.springframework.core.annotation.AnnotationUtils can not access a member of class com.linkedin.restli.server.annotations.RestMethod$ToResourceMethod with modifiers "public abstract" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:105) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253) at java.lang.reflect.Method.invoke(Method.java:599) at org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:400) … {noformat}

    Spring JIRA | 3 years ago | Keli Hlodversson
    java.lang.IllegalAccessException: Class org.springframework.core.annotation.AnnotationUtils can not access a member of class com.linkedin.restli.server.annotations.RestMethod$ToResourceMethod with modifiers "public abstract"
  2. 0

    If a member of a component candidate is annotated with an attribute, that again is annotated with a privately scoped meta-attribute containing values, the scanning will fail with an Illegal state exception caused by an IllegalAccessException caught in org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes. An example where this happens if one uses the rest.li framework in connection with spring: {code:title=RestMethod.java|borderStyle=solid} public class RestMethod { /** * This annotation defines mapping of RestMethod annotations to {@link com.linkedin.restli.common.ResourceMethod} */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) private static @interface ToResourceMethod { ResourceMethod value(); } ... @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @ToResourceMethod(ResourceMethod.GET) public @interface Get { } ... } {code} {code:title=MyComponent.java|borderStyle=solid} @Component .... public class MyComponent extends SomeRestliBaseClass { @RestMethods.Get // Adding this attribute causes the stack trace below public ARecord get (String id) { .... } } {code} {noformat} org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file […]; nested exception is java.lang.IllegalStateException: Could not obtain annotation attribute values at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) … Caused by: java.lang.IllegalStateException: Could not obtain annotation attribute values at org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:432) at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.registerMetaAnnotations(AnnotationAttributesReadingVisitor.java:250) at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.doVisitEnd(AnnotationAttributesReadingVisitor.java:241) at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:167) at org.springframework.asm.ClassReader.a(Unknown Source) at org.springframework.asm.ClassReader.accept(Unknown Source) at org.springframework.asm.ClassReader.accept(Unknown Source) at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) … Caused by: java.lang.IllegalAccessException: Class org.springframework.core.annotation.AnnotationUtils can not access a member of class com.linkedin.restli.server.annotations.RestMethod$ToResourceMethod with modifiers "public abstract" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:105) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253) at java.lang.reflect.Method.invoke(Method.java:599) at org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:400) … {noformat}

    Spring JIRA | 3 years ago | Keli Hlodversson
    java.lang.IllegalAccessException: Class org.springframework.core.annotation.AnnotationUtils can not access a member of class com.linkedin.restli.server.annotations.RestMethod$ToResourceMethod with modifiers "public abstract"
  3. 0

    Cannot call public methods in AbstractBootstrap via reflection

    GitHub | 4 years ago | stuartsierra
    java.lang.IllegalAccessException: Class ReflectionFail can not access a member of class io.netty.bootstrap.AbstractBootstrap with modifiers "public"
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    IllegalAccessException when using the new API

    GitHub | 3 years ago | kelemen
    org.gradle.tooling.BuildActionFailureException: The supplied build action failed with an exception.
  6. 0

    How to invoke private method in Gosu

    Stack Overflow | 5 months ago | Dummy Data
    java.lang.IllegalAccessException: Class program_.__Program__505 can not access a member of class com.guidewire.cc.domain.claim.impl.ClaimSearchCriteriaImpl with modifiers "private"

  1. musketyr 2 times, last 1 month ago
  2. Handemelindo 1 times, last 2 months ago
7 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.IllegalAccessException

    Class org.springframework.core.annotation.AnnotationUtils can not access a member of class com.linkedin.restli.server.annotations.RestMethod$ToResourceMethod with modifiers "public abstract"

    at sun.reflect.Reflection.ensureMemberAccess()
  2. Java RT
    Method.invoke
    1. sun.reflect.Reflection.ensureMemberAccess(Reflection.java:105)
    2. java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
    3. java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
    4. java.lang.reflect.Method.invoke(Method.java:599)
    4 frames
  3. Spring Core
    AnnotationUtils.getAnnotationAttributes
    1. org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:400)
    1 frame