users@jersey.java.net

Re: [Jersey] Subresources not responding to defined routes

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 30 Jul 2010 17:23:51 +0200

On Jul 9, 2010, at 10:37 PM, Basmajian, Raffi wrote:

> I am trying to get a watered-down version of the Bookstore sample
> project working without the JSP pages but with pure XML and JAXB
> instead. I am able to access /items/{id}, but I can't get to the /
> items/{}/track{} or /items/{}/tracks resource. Here is the code:
>
> MusicResource Class
> ====================================================
> @Produces("application/xml")
> @Singleton
> @Path ("/items")
> public class MusicResource {
>
> @GET
> @Path("{cid}/")
> public CD getCD(@PathParam("cid") String cid){}
>

The problem is with the above. The @GET means this is not a sub-
resource locator method but a sub-resource method so what is returned
is considered an entity to be serialized and not a resource.

Paul.


> @GET
> public List<CD> getCDs(){}
>
> CD Class
> ====================================
> @XmlRootElement
> @Produces("application/xml")
> @Singleton
> public class CD {
>
> @GET
> @Path("tracks")
> public List<Track> getTracks() {}
>
> @GET
> @Path("track/{num}/")
> public Track getTrack(@PathParam("num") String tid) {}
>
>
> I just can't figure out why "/items/{}/track/{}" or "/item/{}/
> tracks" is not working. Am I missing an annotation or something?
>
> Thank you,
>
> ------------------------------------------------------------------------------
> This e-mail transmission may contain information that is
> proprietary, privileged and/or confidential and is intended
> exclusively for the person(s) to whom it is addressed. Any use,
> copying, retention or disclosure by any person other than the
> intended recipient or the intended recipient's designees is strictly
> prohibited. If you are not the intended recipient or their designee,
> please notify the sender immediately by return e-mail and delete all
> copies. OppenheimerFunds may, at its sole discretion, monitor,
> review, retain and/or disclose the content of all email
> communications.
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
>