1
votes

I have a pretty simple service that is returning a 500 error - here's the details on the error:

[EL Info]: 2013-11-01 11:09:05.61--ServerSession(741529784)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461

[EL Info]: 2013-11-01 11:09:06.452--ServerSession(741529784)--file:/C:/Users/Fred/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/cheese-ws/WEB-INF/lib/cheese-jpa.jar_cheese login successful

34442 [http-bio-8080-exec-1] ERROR org.apache.wink.server.internal.handlers.FlushResultHandler - The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the java.util.Vector type and application/json mediaType. Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the type and media type specified.

34446 [http-bio-8080-exec-1] INFO org.apache.wink.server.internal.RequestProcessor - The following error occurred during the invocation of the handlers chain: WebApplicationException (500 - Internal Server Error) with message 'null' while processing GET request sent to ...

The code is pretty straightforward and very similar to other services that work fine:

public class StudentTeacherCommunicationService extends BaseService {

@GET
@Path("classroomId/{classroomId}/studentId/{studentId}")

@Produces(MediaType.APPLICATION_JSON)

public List<ClassroomStudentCommunication> getCandidatesAsJson(@PathParam("classroomId") int classroomId, @PathParam("studentId") int studentId) {

    EntityManager em = createEM();

    TypedQuery<ClassroomStudentCommunication> query;

    if(studentId==0) {

        query = em.createQuery("SELECT csc FROM ClassroomStudentCommunication csc where csc.classroomId = :classroomId ORDER BY csc.threadOrder", ClassroomStudentCommunication.class);
        query.setParameter("classroomId", classroomId);

        List <ClassroomStudentCommunication> classCommunication = query.getResultList();

        return classCommunication;

Any ideas?

1
Do you use Maven? If yes, please, show us the pom.xml. - Donato Szilagyi

1 Answers

0
votes

This seems to be a Rest problem not a JPA problem. If you happen to use Maven and generated the project with an archetype or IDE, it is worth to check the generated pom.xml. JSON support can be turned off by default in the pom.xml.

For example if you use Jersey and your project is generated with jersey-quickstart-webapp archetype then you should uncomment the following section manually in the pom.xml:

<!-- uncomment this to get JSON support
<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-moxy</artifactId>
</dependency>
-->