异常: AbstractMethodError: javax.ws.rs.core.Response.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType;

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20616351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 03:10:03  来源:igfitidea点击:

Exception: AbstractMethodError: javax.ws.rs.core.Response.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType;

javajaxbjax-rsjersey-client

提问by sschober

When trying a POST-Request using jersey 1.18, I get the following exception:

使用 jersey 1.18 尝试 POST-Request 时,出现以下异常:

Exception in thread "main" java.lang.AbstractMethodError: javax.ws.rs.core.Response.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType;
at javax.ws.rs.WebApplicationException.computeExceptionMessage(WebApplicationException.java:205)
at javax.ws.rs.WebApplicationException.<init>(WebApplicationException.java:179)
at javax.ws.rs.WebApplicationException.<init>(WebApplicationException.java:244)
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:159)
at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:217)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:153)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.sun.jersey.api.client.WebResource.voidHandle(WebResource.java:706)
at com.sun.jersey.api.client.WebResource.access0(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:555)
at jtmt.shell.commands.upld.TrcUploader.upload(TrcUploader.java:29)
at jtmt.shell.commands.trcrt.ICMPTraceRoute.run(ICMPTraceRoute.java:92)
at jtmt.shell.commands.Main.<init>(Main.java:42)
at jtmt.shell.commands.Main.main(Main.java:64)

The code that produces this is:

产生这个的代码是:

    Trace trc = Trace.fromTracerouteResult(trace);
    WebResource wr = _c.resource(URL);
    WebResource.Builder wrb = wr.cookie(new Cookie("user", USER));
    wrb = wrb.cookie(new Cookie("auth", AUTH));
    wrb.post(trc);
    return true;

The entiry Tracelooks like this:

整个内容Trace如下所示:

@XmlRootElement
public class Trace {
    private Map<Integer,List<String>> addressesPerHop;
    private String source;
    private String traget;

    /* getters and setters */
}

I include the following jars when compiling and executing:

我在编译和执行时包含以下 jars:

commons-cli-1.2.jar
jersey-server-1.18.jar
asm-3.1.jar
jersey-servlet-1.18.jar
jersey-client-1.18.jar
jersey-core-1.18.jar

Any Ideas whats missing?

任何想法缺少什么?

采纳答案by EJK

Short answer: Your version of Jersey is too old. The method javax.ws.rs.core.Response.getStatusInfo() is part of the 2.0 JAX-RS spec. See: https://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/core/Response.html#getStatusInfo().

简短回答:您的 Jersey 版本太旧了。方法 javax.ws.rs.core.Response.getStatusInfo() 是 2.0 JAX-RS 规范的一部分。请参阅:https: //jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/core/Response.html#getStatusInfo()

Jersey 2.0 appears to be the first version that supports JAX-RS 2.0.

Jersey 2.0 似乎是第一个支持 JAX-RS 2.0 的版本。