正式使我感到困惑的是这个障碍。
我已经将Jersey从2.4.1升级到2.5.1,因为Jersey / Oracle修复了一个软件包扫描错误,该错误会影响Swagger的正常运行。在与基于Spring的服务器集成很多黑客之后,2.4.1的工作相对“正常”(spring- jersey3 根本无法工作现在,由于升级到2.5.1(现在是2.6-SNAPSHOT),我收到了每当我向与API URL模式匹配的任何内容发出请求时,都会出现以下错误。
我做了什么:
帮助/解决方法/调试想法大受赞赏…甚至不知道我除了清除Swagger,几天的工作并回滚到2.4.1还能做什么。
Feb 12, 2014 15:46:24 ERROR [TP-Processor6] [Catalina].[localhost].[/company [Jersey REST Service] - Servlet.service() for servlet Jersey REST Service threw exception java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.collection.Values.lazy(Lorg/glassfish/jersey/internal/util collection/Value;)Lorg/glassfish/jersey/internal/util/collection/Value; at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.company.videoapp.server.springframework.SessionFilter.doFilter(SessionFilter.java:44) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.company.videoapp.server.springframework.loader.ContextLoaderHttpInterceptor$LoaderState.filter(ContextLoaderHttpInterceptor.java:75) at com.company.videoapp.server.springframework.loader.ContextLoaderHttpInterceptor$StartedState.filter(ContextLoaderHttpInterceptor.java:120) at com.company.videoapp.server.springframework.loader.ContextLoaderHttpInterceptor.doFilter(ContextLoaderHttpInterceptor.java:62) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705) at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) at java.lang.Thread.run(Thread.java:662)
我摆脱了无处不在的500错误, 但是我仍然得到那个异常 。以下是一些观察结果-
500
接口…继承…在2.5.1+中有很多错误(至少有两个回归错误。)
我经常出现500个错误是由于这个原因,所以在删除接口后,我 至少 可以命中一个有效的端点。以下情况:
@Path(MY_PATH) @Produces(...) @Consumes(...) interface MyResource { ... @GET myResourceMethod(); }
。
public class MyAwesomeResource implements MyResource { ... }
向上述资源发送请求会导致404异常,500由于与上述异常有关的一些未知问题,反过来又会导致客户端的。
404
@Path(MY_PATH) @Produces(...) @Consumes(...) public interface MyResource { ... @GET myResourceMethod(); }
500 向资源发出请求时,内部NoSuchMethodError异常会导致另一个(注释中的一个-“在MyResource.class中找不到合适的构造函数”)
原始问题中发布的异常掩盖了真正的异常(404变成500…我必须进行远程调试才能看到实际的异常。)
希望泽西岛的开发者正在注意这一点。不酷
根据JERSEY-2394中提供的信息,您的类路径包含以下库:
rw-rr- 1 root root 94774 Feb 10 12:02 cxf-rt-databinding-jaxb-2.3.2.jar rw-rr- 1 root root 341446 Feb 10 12:02 cxf-rt-frontend-jaxws-2.3.2.jar rw-rr- 1 root root 20020 Feb 10 12:02 jackson-jaxrs-base-2.2.3.jar rw-rr- 1 root root 15243 Feb 10 12:02 jackson-jaxrs-json-provider-2.2.3.jar rw-rr- 1 root root 25985 Feb 10 12:02 jackson-module-jaxb-annotations-2.2.3.jar rw-rr- 1 root root 50034 Feb 10 12:02 jackson-module-jsonSchema-2.1.0.jar rw-rr- 1 root root 79309 Feb 10 12:02 javax.json-1.0.2.jar rw-rr- 1 root root 19754 Feb 10 12:02 javax.json-api-1.0.jar rw-rr- 1 root root 876610 Feb 10 12:02 jaxb-impl-2.1.13.jar rw-rr- 1 root root 226915 Feb 10 12:02 jaxen-1.1.1.jar rw-rr- 1 root root 159742 Feb 10 14:02 jersey-client-2.5.1.jar rw-rr- 1 root root 700399 Feb 10 14:02 jersey-common-2.5.1.jar rw-rr- 1 root root 15684 Feb 10 14:02 jersey-container-servlet-2.5.1.jar rw-rr- 1 root root 52593 Feb 10 12:02 jersey-container-servlet-core-2.1.jar rw-rr- 1 root root 6412 Feb 10 14:02 jersey-media-json-processing-2.5.1.jar rw-rr- 1 root root 63067 Feb 10 12:02 jersey-media-multipart-2.1.jar rw-rr- 1 root root 828016 Feb 10 14:02 jersey-server-2.5.1.jar rw-rr- 1 root root 86540 Feb 10 12:02 json4s-ast_2.10-3.2.4.jar rw-rr- 1 root root 568890 Feb 10 12:02 json4s-core_2.10-3.2.4.jar rw-rr- 1 root root 74565 Feb 10 12:02 json4s-ext_2.10-3.2.4.jar rw-rr- 1 root root 39952 Feb 10 12:02 json4s-jackson_2.10-3.2.4.jar rw-rr- 1 root root 68734 Feb 10 12:02 json4s-native_2.10-3.2.4.jar rw-rr- 1 root root 7814 Feb 10 12:02 jsonp-jaxrs-1.0.jar rw-rr- 1 root root 121047 Feb 10 12:02 swagger-jaxrs_2.10-1.3.2.jar rw-rr- 1 root root 45719 Feb 10 12:02 swagger-jersey2-jaxrs_2.10-1.3.2.jar
您有2个版本不同于2.5.1- jersey-media-multipart-2.1.jar和的Jersey jar jersey- container-servlet- core-2.1.jar。后者会导致您遇到问题。stacktrace中的行与以下想法相对应:使用2.1版本的jersey servlet核心而不是2.5.1(请参阅2.1中的WebComponent)。解决方法是删除旧的jar。
jersey-media-multipart-2.1.jar
jersey- container-servlet- core-2.1.jar