我正在使用Jersey 2.9和Jackson,在这里你可以找到依赖项:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
当我执行此客户端代码时,我有一些像Student.class这样的POJO类,其中包含一些属性:
Student studentRequest = new Student();
Response response = target()
.path("/students/register")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.json(studentRequest), Response.class);
代码不起作用,我得到了这个例外:
javax.ws.rs.ProcessingException: com.fasterxml.jackson.jaxrs.base.ProviderBase._configForWriting(Lcom/fasterxml/jackson/databind/ObjectWriter;[Ljava/lang/annotation/Annotation;)Lcom/fasterxml/jackson/jaxrs/cfg/EndpointConfigBase;
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:233)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655)
...
at
Caused by: java.lang.AbstractMethodError: com.fasterxml.jackson.jaxrs.base.ProviderBase._configForWriting(Lcom/fasterxml/jackson/databind/ObjectWriter;[Ljava/lang/annotation/Annotation;)Lcom/fasterxml/jackson/jaxrs/cfg/EndpointConfigBase;
at com.fasterxml.jackson.jaxrs.base.ProviderBase._configForWriting(ProviderBase.java:469)
...
任何人都知道为什么我会得到这个堆栈跟踪?
谢谢!
答案 0 :(得分:0)
遇到同样的问题,在我的例子中,它通过maven依赖管理系统将实现作为依赖关系添加到pom.xml中的客户端来帮助修复java.lang.AbstractMethodError:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.2</version>
</dependency>