-
Notifications
You must be signed in to change notification settings - Fork 38.5k
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy exception when annotation config not found needs to specify what class is not found [SPR-10441] #15074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hendy Irawan commented I got hit by this again Solution #1: Run mvn install Solution #2: In Eclipse IDE, remove the webapp project (web resource) from Tomcat Server, then re-add. |
Stéphane Nicoll commented -Could you provide a sample project or at least a full stack trace?- How is this workflow failing exactly? If I understand correctly, you have two modules and you are performing a refactoring that affects both modules: in module A you rename This is compiling fine in your IDE but your jetty server is using a different classpath (the local repository and not the modified sources that have been compiled by your IDE. Am I missing anything here? Thanks. |
Juergen Hoeller commented I haven't seen such an exception before, and I'm wondering how to arrive at such a state of things as well. That said, it looks like we can code defensively in any case there, catching unexpected annotation lookup exceptions and rethrowing them with richer introspection context from our side. Juergen |
Hendy Irawan commented Simple way to reproduce:
Before running webserver (Tomcat, Jetty, anything), remove the "WEB-INF/classes/somepackage/OtherConfig.class" file. Then run. The reason is Spring tries to call Without any clue to which class Spring is processing, it's hard to diagnose this problem for the app developer. So Spring should catch the Exception thrown by |
Hendy Irawan commented IMHO this is a specialization of ClassNotFoundException. However CNFE is quite helpful that it gives the name of the class not found. This exception doesn't give anything (neither "MyConfig" nor the "OtherConfig" class, nor the "Import" annotation). |
Stéphane Nicoll commented Hendy, I have provided a sample project that can be used to reproduce the issue. Please have a look to it and confirm that's what you're having: |
Hendy Irawan commented Stéphane Nicoll Yes exactly! :) |
Juergen Hoeller commented AnnotatedElementUtils wraps unexpected exceptions with a descriptive IllegalStateException now, including the AnnotatedElement (Class/Method) toString representation. Juergen |
Hendy Irawan commented Thank you Juergen Hoeller so much! awesome :) |
Ken Kruger commented Juergen, Phil, Hendry - Thanks for discovering and fixing this issue. This improved debugging information just saved my bacon. I had no idea what was wrong using 4.0.2. Kudos. |
Tim Meighen commented I think this issue may have cropped up again starting with 4.1.7.RELEASE. I'm having the problem with 4.3.2.RELEASE and came across this issue. I downloaded the sample issue here: https://github.com/spring-projects/spring-framework-issues/tree/master/SPR-10441 and I get the enhanced info up to 4.1.6.RELEASE: Exception in thread "main" java.lang.IllegalStateException: Failed to introspect annotations: class org.springframework.issues.SampleApp$AppConfig From 4.1.7.RELEASE onwards I no longer get the IllegalStateException and just get: Exception in thread "main" java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy |
Uh oh!
There was an error while loading. Please reload this page.
Hendy Irawan opened SPR-10441 and commented
It happened for me when I used Spring Configuration annotation like this:
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.
Affects: 3.2.2
Issue Links:
Referenced from: commits ac61b13
0 votes, 6 watchers
The text was updated successfully, but these errors were encountered: