我是网络服务的新手。我尝试将jax.ws..
Web 服务与jersey
和一起使用spring
。当我尝试使用Chrome Post Client
或CURL
在 Windows 中发送请求时,会发生以下堆栈跟踪。
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
实体映射,但我不确定。