Repository navigation
Closed
Description
zhangchunhua opened SPR-13696 and commented
@RestController
public class UserController {
@RequestMapping(path = "/user", method = RequestMethod.GET)
@JsonView(User.WithoutPasswordView.class)
public User getUser() {
return new User("eric", "7!jd#h23");
}
}
java.lang.IllegalArgumentException: interface org.springframework.core.annotation.SynthesizedAnnotation is not visible from class loader
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:581)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
at java.lang.reflect.WeakCache.get(WeakCache.java:127)
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
at org.springframework.core.annotation.AnnotationUtils.synthesizeAnnotation(AnnotationUtils.java:1404)
at org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(AnnotatedElementUtils.java:405)
at org.springframework.web.method.HandlerMethod.getMethodAnnotation(HandlerMethod.java:234)
at org.springframework.web.method.HandlerMethod$HandlerMethodParameter.getMethodAnnotation(HandlerMethod.java:290)
at org.springframework.web.servlet.mvc.method.annotation.JsonViewResponseBodyAdvice.supports(JsonViewResponseBodyAdvice.java:50)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyAdviceChain.processBody(RequestResponseBodyAdviceChain.java:147)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyAdviceChain.beforeBodyWrite(RequestResponseBodyAdviceChain.java:138)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:217)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:153)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:165)
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:412)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Affects: 4.2.3
Reference URL: #18212
Issue Links:
- IllegalArgumentException when using AnnotationUtils.findAnnotation [SPR-13634] #18212 IllegalArgumentException when using AnnotationUtils.findAnnotation
- Regression: Spring 4.2.4 fails to load configuration class on Google App Engine [SPR-13829] #18402 Regression: Spring 4.2.4 fails to load configuration class on Google App Engine
Referenced from: commits d081470
0 votes, 7 watchers
Activity
spring-projects-issues commentedon Nov 18, 2015
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.
spring-projects-issues commentedon Nov 19, 2015
zhangchunhua commented
I do not use Swagger by any chance .I just used JsonView as followed:
@RestControllerpublic class UserController {
@RequestMapping(path = "/user", method = RequestMethod.GET)@JsonView(User.WithoutPasswordView.class)public User getUser()
{ return new User("eric", "7!jd#h23"); }
}
In Spring4.2.2 ,this case is ok.
But in Spring 4.2.3,when entering UserController ,IllegalArgumentException is throwed.
spring-projects-issues commentedon Nov 19, 2015
Stéphane Nicoll commented
Are you sure you don't have mixed versions of the framework? Can you run
mvn dependencies:liston your project and check that all the Spring jars are using only4.2.3.RELEASE? If that's the case, please share a project that reproduces the problem.spring-projects-issues commentedon Nov 21, 2015
zhangchunhua commented
Thank you very much.
I changed my web project into maven project.
When I used mvn dependencies, spring4.2.3.RELEASE jars and other Dependent jars automatically were downloaded.
In this case,the IllegalArgumentException is no longer throwed.This case came to be OK.
spring-projects-issues commentedon Nov 24, 2015
zhangchunhua commented
I am sorry.I am another problem.
The same Project deployed in Tomcat,it is OK.
But deployed in glassfish4.1,IllegalArgumentException is always throwed.
I see that AnnotationUtils is modified form Proxy.newProxyInstance(ClassUtils.getDefaultClassLoader() to Proxy.newProxyInstance(annotation.getClass().getClassLoader().
Is it the reason?
My project Link:https://github.com/syw2452/git_syw.git
spring-projects-issues commentedon Nov 25, 2015
zhangchunhua commented
In glassfish4.1,this problem still exist
spring-projects-issues commentedon Nov 25, 2015
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.
spring-projects-issues commentedon Dec 5, 2015
D K commented
Not really sure why this is closed but I think there is a bug in the public api of
AnnotatedElementUtils.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.getMethodAnnotationchanged fromHere 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.
Would you like me to create a new bug for this?
spring-projects-issues commentedon Dec 5, 2015
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
spring-projects-issues commentedon Dec 7, 2015
Juergen Hoeller commented
We are explicitly checking whether the
SynthesizedAnnotationmarker is exposable to the annotation's ownClassLoadernow. If not, we simply expose a plain annotation proxy without that marker type.In order to nevertheless detect pre-synthesized annotations, we also check for the annotation proxy's
InvocationHandler: If it's our internal one, we consider the annotation as pre-synthesized as well.Juergen
spring-projects-issues commentedon Dec 8, 2015
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).
Also see: springfox/springfox#1055
spring-projects-issues commentedon Dec 8, 2015
Juergen Hoeller commented
Please give the latest
4.2.4.BUILD-SNAPSHOTa try and let me know whether it works for you there...Juergen
spring-projects-issues commentedon Dec 10, 2015
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...
spring-projects-issues commentedon Dec 10, 2015
Stéphane Nicoll commented
What
RELEASE-BUILD? As Juergen point out, the proper version is4.2.4.BUILD-SNAPSHOT.spring-projects-issues commentedon Dec 10, 2015
Thibault Kruse commented
Sorry, that's what I meant. 4.2.4.BUILD-SNAPSHOT is not defined for spring-test, spring-context, spring-aop.
See here:
https://repo.spring.io/snapshot/org/springframework/spring-context/4.2.4.BUILD-SNAPSHOT/
All poms are timestamped, and my maven thus does not seem to find 4.2.4.BUILD-SNAPSHOT. Maybe I did something else wrong...
spring-projects-issues commentedon Dec 10, 2015
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?
spring-projects-issues commentedon Dec 11, 2015
Thibault Kruse commented
ok, sorry for the confusion. 4.2.4.BUILD-SNAPSHOT seems to work for me.