Values.lazy上的NoSuchMethodError(Jersey 2.5.1)

时间:2014-02-13 00:05:07

标签: api rest tomcat jersey jersey-2.0

我被这个阻挡者正式困惑。

我已将Jersey从2.4.1升级到2.5.1,因为Jersey / Oracle修复了一个影响获取Swagger工作的软件包扫描错误。 2.4.1在与我们的基于Spring的服务器(spring-jersey3是not working at all)集成之后,工作相对“正常”。现在自升级到2.5.1(现在,2.6-SNAPSHOT),我每次我向符合API网址格式的任何内容发出请求时,都会收到以下错误。

我做了什么:

  • 在新的干净服务器上重新部署(干净的maven存储库,干净的tomcat等);
  • 检查jar是否是正确的版本(甚至反编译“Value”类以确保它是我在GitHub上看到的那个〜2个月前更新过的);
  • 使用tattletale查看所有罐子以查找类冲突;
  • 升级到2.6-SNAPSHOT(如上所述),构建latest;
  • 发布了bug(无回复);

帮助/解决方法/调试的想法非常感谢...甚至不知道除了报废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错误,但我仍然得到了异常。以下是一些观察结果 -

2.5.1& 2.6-SNAPSHOT

接口......继承... 2.5.1+中的非常错误(至少有两个回归错误。)

我的常量500错误是由于这个原因造成的,所以删除接口后我至少命中了一个有效的端点。下面的场景:

场景破碎#1 - 实施资源界面

@Path(MY_PATH)
@Produces(...)
@Consumes(...)
interface MyResource {
   ...
   @GET myResourceMethod();
}

public class MyAwesomeResource implements MyResource {
   ...
}
  

向上述资源发送请求会导致404异常,从而导致客户端出现500,因为某些未知问题可能与上述异常有关。< / em>的

场景破碎#2 - 使界面公开

@Path(MY_PATH)
@Produces(...)
@Consumes(...)
public interface MyResource {
   ...
   @GET myResourceMethod();
}

public class MyAwesomeResource implements MyResource {
   ...
}
  

在向资源发出请求时,从内部NoSuchMethodError异常(注释中的那个 - “在MyResource.class中找不到合适的构造函数”)中的另一个500结果

原始问题中发布的异常是掩盖实际异常(404变为500 ...我必须远程调试才能看到实际异常。)

希望泽西队的开发者正在关注这一点。不酷。

1 个答案:

答案 0 :(得分:3)

根据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.jarjersey-container-servlet-core-2.1.jar。后者会导致您遇到的问题。来自堆栈跟踪的行符合使用2.1版本的jersey servlet core而不是2.5.1的想法(参见2.1中的WebComponent)。解决方案是移除旧罐子。