-
Notifications
You must be signed in to change notification settings - Fork 38k
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
SynthesizedAnnotation is not visible from class loader [SPR-13696] #18271
Comments
Stéphane Nicoll commented Are you using Swagger by any chance? If so please try to remove it to see if the error goes away. We already got several reports with that same exception and Swagger was the root cause every single time. |
zhangchunhua commented I do not use Swagger by any chance .I just used JsonView as followed:
} In Spring4.2.2 ,this case is ok. |
Stéphane Nicoll commented Are you sure you don't have mixed versions of the framework? Can you run |
zhangchunhua commented Thank you very much. |
zhangchunhua commented I am sorry.I am another problem. My project Link:https://github.com/syw2452/git_syw.git |
zhangchunhua commented In glassfish4.1,this problem still exist |
Stéphane Nicoll commented This issue is related to a wrong usage of the framework and mixed jars as we already concluded. Your sample project does not use standard Spring libraries and the fact it works in tomcat is even more suspicious. As this is a usage problem, please ask on stackoverflow and the community will hopefully assist you. |
D K commented Not really sure why this is closed but I think there is a bug in the public api of Related to the allusion of cause of the exception to swagger, I believe there is a breaking change (at runtime), that was introduced in 4.2 when the implementation of // HandlerMethod.getMethodAnnotation implementation changed from:
return AnnotationUtils.findAnnotation(this.method, annotationType);
//to:
return AnnotatedElementUtils.findMergedAnnotation(this.method, annotationType); Here is a simple test to prove it. When asking AnnotationElementUtils for an annotation that belongs the the java lang package (Deprecated) it fails with the reported exception. public class AClass {
@Deprecated
public void aMethod() {
}
}
public class ATest {
@Test
public void testAnnotation() throws NoSuchMethodException {
AnnotatedElement method = AClass.class.getMethod("aMethod");
AnnotatedElementUtils.findMergedAnnotation(method, Deprecated.class);
}
} Would you like me to create a new bug for this? |
Juergen Hoeller commented Let's reopen this one and repurpose it a bit: The hint with lookup of a JDK annotation is key here, since it'll be hard to synthesize those to begin with. In particular, we need to pay attention which class loader we're using for the synthesized type. Juergen |
Juergen Hoeller commented We are explicitly checking whether the In order to nevertheless detect pre-synthesized annotations, we also check for the annotation proxy's Juergen |
Thibault Kruse commented Same problem, using swagger via com.mangofactory:swagger-springmvc and switched from 4.2.2 to 4.2.3. Not mixing Spring library version (though using Spring security 4.0.3). |
Juergen Hoeller commented Please give the latest Juergen |
Thibault Kruse commented That's rather painful, as of now, 4.2.4.RELEASE-BUILD does not exist for e.g. spring-test or spring-context, spring-aop... |
Stéphane Nicoll commented What |
Thibault Kruse commented Sorry, that's what I meant. 4.2.4.BUILD-SNAPSHOT is not defined for spring-test, spring-context, spring-aop. All poms are timestamped, and my maven thus does not seem to find 4.2.4.BUILD-SNAPSHOT. Maybe I did something else wrong... |
Stéphane Nicoll commented snapshot builds are always timestamped. I don't know what you're doing but it works for me. Maybe you need to add the spring snapshots repo in your pom? <repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories> |
Thibault Kruse commented ok, sorry for the confusion. 4.2.4.BUILD-SNAPSHOT seems to work for me. |
zhangchunhua opened SPR-13696 and commented
Affects: 4.2.3
Reference URL: #18212
Issue Links:
Referenced from: commits d081470
0 votes, 7 watchers
The text was updated successfully, but these errors were encountered: