Description
Hendy Irawan opened SPR-10441 and commented
It happened for me when I used Spring Configuration annotation like this:
@Configuration
@Import({ Config.class })
public class WebConfig extends WebMvcConfigurerAdapter
{
...
}
When I renamed Config.class to CoreConfig.class the error occurred when starting jetty. this happened because the CoreConfig.class was in a different sub module of my maven project, so jetty couldn't see it (as it resolves dependencies through mvn local repository).
After calling 'mvn install' everything was fine again.
This is a packaging problem on user's part. Some class is not on the classpath.
as described in http://stackoverflow.com/questions/11823288/java-lang-arraystoreexception-sun-reflect-annotation-typenotpresentexceptionpro
However the exception stacktrace does not mention what class cannot be found by Spring. So locating the culprit in a large project is very difficult and time consuming.
Spring should pinpoint the affected class, who loads that class, so app developer can fix it.
Exception in thread "main" java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3178)
at java.lang.Class.getAnnotations(Class.java:3158)
at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:159)
at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:152)
at org.springframework.core.annotation.AnnotatedElementUtils.isAnnotated(AnnotatedElementUtils.java:72)
at org.springframework.core.type.StandardAnnotationMetadata.isAnnotated(StandardAnnotationMetadata.java:102)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:72)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:62)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:140)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:127)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:122)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.register(AnnotationConfigApplicationContext.java:151)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:83)
at org.springframework.issues.SampleApp.main(SampleApp.java:12)
Affects: 3.2.2
Issue Links:
- Useless exception message when annotations can't be parsed [SPR-12507] #17112 Useless exception message when annotations can't be parsed ("is duplicated by")
- AnnotationUtils.findAnnotation fails with poor diagnostics if it encounters an Annotation that references an unloadable class [SPR-11874] #16493 AnnotationUtils.findAnnotation fails with poor diagnostics if it encounters an Annotation that references an unloadable class
- Improve diagnostics when AnnotationAttributesReadingVisitor triggers an ArrayStoreException from Class.getAnnotations() [SPR-12387] #16995 Improve diagnostics when AnnotationAttributesReadingVisitor triggers an ArrayStoreException from Class.getAnnotations()
Referenced from: commits ac61b13
0 votes, 6 watchers