gpt4 book ai didi

java - Rest Web 服务中的 AbstractMethodError

转载 作者:行者123 更新时间:2023-12-02 13:14:42 29 4
gpt4 key购买 nike

我是网络服务新手。我尝试将 jax.ws.. Web 服务与 jerseyspring 一起使用。当我尝试在 Windows 中使用 Chrome Post ClientCURL 发送请求时,会发生以下堆栈跟踪。

SEVERE: Servlet.service() for servlet [jersey-serlvet] in context with path [/rest] threw exception [Servlet execution threw an exception] with root cause
java.lang.AbstractMethodError
at org.codehaus.jackson.map.AnnotationIntrospector$Pair.findDeserializer(AnnotationIntrospector.java:1335)
at org.codehaus.jackson.map.deser.BasicDeserializerFactory.findDeserializerFromAnnotation(BasicDeserializerFactory.java:675)
at org.codehaus.jackson.map.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:535)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createDeserializer(StdDeserializerProvider.java:432)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCache2(StdDeserializerProvider.java:341)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCacheValueDeserializer(StdDeserializerProvider.java:321)
at org.codehaus.jackson.map.deser.StdDeserializerProvider.findValueDeserializer(StdDeserializerProvider.java:167)
at org.codehaus.jackson.map.deser.StdDeserializerProvider.findTypedValueDeserializer(StdDeserializerProvider.java:188)
at org.codehaus.jackson.map.ObjectMapper._findRootDeserializer(ObjectMapper.java:2820)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2690)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1308)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
..............................

以下是我的示例代码:

@Path("/loginPoint")
@Service
public class UserService {

@Resource(name= "commanUserService")
private CommanUserService commanUserService;

@POST
@Path("/login")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response login(LoginRequest request){
System.out.println("Hello In web Services >>>>>>>>>>>>>>>>>>>>>>>>> ");
LoginResponse response = commanUserService.getUserloginInformation(request);
return Response.status(Status.OK).entity(response).build();
}
}

LoginRequest.java 文件代码:

@XmlRootElement(name="loginRequest")
public class LoginRequest {
private String userName;
private String password;

@XmlElement("userName")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}

@XmlElement("password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

我认为问题在于将 JSON 请求参数与 LoginRequest 实体映射,但我不确定。

最佳答案

问题是 Jackson 版本之间不匹配。

关于java - Rest Web 服务中的 AbstractMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18465819/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com