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

时间:2013-12-16 16:58:47

标签: java jaxb jax-rs jersey-client

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

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.access$400(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)

产生此代码的代码是:

    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;

entiry Trace看起来像这样:

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

    /* getters and setters */
}

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

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

任何想法都丢失了?

1 个答案:

答案 0 :(得分:9)

简短回答:你的泽西岛版本太旧了。方法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似乎是第一个支持JAX-RS 2.0的版本。