简体   繁体   English

使用球衣2.0时出现NoSuchMethodError

[英]NoSuchMethodError when using jersey 2.0

I'm using jersey 2.0 and when performing a request I'm getting the following exception: 我正在使用jersey 2.0,并且在执行请求时出现以下异常:

SEVERE: StandardWrapper.Throwable
java.lang.NoSuchMethodError: com.google.common.collect.Sets.newIdentityHashSet()Ljava/util/Set;
    at org.glassfish.jersey.model.internal.CommonConfig.<init>(CommonConfig.java:215)
    at org.glassfish.jersey.server.ResourceConfig$State.<init>(ResourceConfig.java:107)
    at org.glassfish.jersey.server.ResourceConfig.<init>(ResourceConfig.java:338)
    at org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:373)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:259)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:865)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

These are the jars I'm using: 这些是我正在使用的罐子:

在此处输入图片说明

I guess I have some problem with the jars I'm using but I can't figure out what is missing. 我想我所用的罐子有些问题,但我无法弄清缺少的东西。 I'm not using maven so I'm consuming the jars directly. 我不使用Maven,所以直接使用Jar。

In addition, I'm also implementing a filter (ContainerResponseFilter) in my app, maybe it has something to do with the exception, I don't know. 另外,我还在我的应用程序中实现了一个过滤器(ContainerResponseFilter),也许它与异常有关,我不知道。

This is probably caused by different, incompatible versions of Google Collections (now part of Guava) in your dependencies. 这可能是由于您的依存关系中存在不同的,不兼容的Google收藏夹版本(现在是Guava的一部分)引起的。 The Jersey library was compiled against one version of this and now during runtime a different version of it is loaded first. Jersey库是针对该版本的一个版本进行编译的,现在在运行时会首先加载该版本的另一个版本。 Try excluding one of google-collections or guava-collections from your dependencies. 尝试从依赖项中排除google-collection或guava-collection之一。

I solved the problem. 我解决了问题。 Basically my jars probably didn't match. 基本上我的罐子可能不匹配。 This answer helped we a lot. 这个答案对我们有很大帮助。 You can find there a list of all required jars. 您可以在此处找到所有所需罐子的列表。 I have the exact same list and it's working. 我有完全相同的列表,并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM