1
votes

I have these 2 methods below defined in my restful resource class. I'm using Jersey. But when I try to run a unit it says error, they have the same media type. Am I missing something ?

SEVERE: The following errors and warnings have been detected with resource and/or provider classes: SEVERE: Producing media type conflict. The resource methods public javax.ws.rs.core.Response com.thomsonreuters.codes.sourcedocweb.resource.DocumentsResource.findDocumentMetadataByCorId(java.lang.String) and public javax.ws.rs.core.Response com.thomsonreuters.codes.sourcedocweb.resource.DocumentsResource.findDocumentMetadata(java.lang.String) can produce the same media type Feb 11, 2013 5:43:56 PM com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory$InMemoryTestContainer stop INFO: Stopping low level InMemory test container

@GET
@Path("/{docId}/metadata")
@Produces(MediaType.APPLICATION_XML)
public Response findDocumentMetadata(@PathParam("docId")
final String docId)
{
    Response response = findMetadataForDocument(docId);

    return response;
}


@GET
@Path("/{corid}/metadata")
@Produces(MediaType.APPLICATION_XML)
public Response findDocumentMetadataByCorId(@PathParam("corid")
final String corid)
{
    Response response = findMetadataForDocument(corid);

    return response;
}
1

1 Answers

2
votes

The first thing I notice is that the two paths will conflict. Jersey doesn't have any frame of reference to know if /1/metadata should be routed to the first or second method. You might try defining your paths as /doc/metadata/{docid} and /cor/metadata/{corid}. Hope this helps.