NoSuchMethodError: MultivaluedMap.addAll in Jersey Client

前端 未结 3 2044
予麋鹿
予麋鹿 2020-12-03 13:29

I\'m trying to use Jersey Client to simulate HTTP requests to my web service. I tried to implement the simple example from the documentation. Here\'s my short code:

3条回答
  •  甜味超标
    2020-12-03 14:08

    This looks like an inconsistency pertaining to the JAX-RS API version (which contains the MultiValuedMap).

    You are using client jersey-client v2.2, which is compiled against v2.0 of the JAX-RS API. But your runtime states to run with Java EE 6, which defines JAX-RS API v1.1. So your code expects v2.0 of the JAX-RS API, but gets v1.1 at runtime.

    This is the MultiValuedMap API for Java EE 6:

    http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/MultivaluedMap.html (no addAll method).

    And for Java EE 7:

    http://docs.oracle.com/javaee/7/api/javax/ws/rs/core/MultivaluedMap.html (this one includes the addAll method).

    As you are using Java EE 6, you should be using jersey-client v1.8, not 2.2. Or you should be including the Java EE 7 API in your runtime classpath, and not 6.

提交回复
热议问题