问题
I am trying to execute a RESTful web service deployed on tomcat using Jersey implementation.
Following is the resource class
@Path("/rest") public class PatientResource {
PatientService patientService;
@GET
@Path("/patient/{patientId}")
@Produces(MediaType.APPLICATION_JSON)
public Patient getPatientDetails(@PathParam("patientId") String patientId) {
//return patientService.getPatientDetails(patientId);
return new PatientService().getPatientDetails(patientId);
}
@GET
@Path("/patients")
@Produces(MediaType.APPLICATION_JSON)
public PatientData<Patient> getAllPatients() {
//return patientService.getAllPatients();
return new PatientService().getAllPatients();
}
}
I have made necessary entries in web.xml and all necessary jars are available in classpath, however when application is started on tomcat and I enter the URL in browser, I get following exception
[Servlet execution threw an exception] with root cause java.lang.AbstractMethodError at org.codehaus.jackson.map.AnnotationIntrospector$Pair.findSerializer(AnnotationIntrospector.java:1148) at org.codehaus.jackson.map.ser.BasicSerializerFactory.findSerializerFromAnnotation(BasicSerializerFactory.java:367) at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:252) at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:782)
Any idea how to resolve it ?
回答1:
Probably an inconsistency in the versions of Jersey and Jackson you are using at runtime .
What are your libs versions ?
来源:https://stackoverflow.com/questions/14954738/runtime-exception-with-jersey-java-lang-abstractmethoderror