Reputation: 6611
I am new in web service. I try to using jax.ws..
web service with jersey
and spring
. When i try to send the request using Chrome Post Client
or CURL
in windows, following stack trace occur.
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)
..............................
Following is the code of my example :
@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 file code :
@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;
}
}
I suppose that problem is in mapping JSON
request parameters with LoginRequest
entity, but i am not sure.
Upvotes: 2
Views: 4188
Reputation: 2068
I got the same issue and resolved myself. the issue was with the version compatibility between jersy(jersy-json, jersy-server) and jackson(jackson-core-asl, jackson-mapper-asl) jars.
so please use compatible versions like jersy 1.8 with jackson 1.8.1 jars.
Upvotes: 3
Reputation: 1735
When using jackson-core-asl dependency with jackson-mapper-asl becareful on choosing same version.
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
Upvotes: 3