Hi,

The Path values you've specified are perfectly fine, it does not really matter 
whether you have
@Path("/catalog") or @Path("/catalog/") for a URI like "/catalog/item/1" 
matched against the method
annotated with "/catalog/item/1". This is due to a selection algorithm defined 
by JAXRS authors.

It's really a bug in SoapUI. For example, a CXF Client API uses another good 
JAX-RS piece which is UriBuilder which
takes care of duplicate or missing slashes, etc. So yes, either remove a trailing slash from @Path("/catalog/") or remove a leading one from "/catalog/item/{id}" to have SoapUI working better.

Now as far as a trailing slash is concerned it can make a difference when 
selecting between multiple candidates. Example :

@Path("catalog")
public class Catalog1 {
  @GET
  List<Item> getAll() {}
}

@Path("catalog/")
@XmlRootElement
public class Catalog2 {

  @GET
  Catalog2 get() {}

  @GET
  @Path("/item/{id}")
  Item getIteam(@PathParam("id") int i) {}
}

"GET /catalog" will result in Catalog1 root resource class being selected, and 
its getAll() method being called.
"GET /catalog/" will result in Catalog2 root resource class being selected, and 
its get() method being called.

cheers, Sergey

----- Original Message ----- From: "KARR, DAVID (ATTCINW)" <[email protected]>
To: <[email protected]>
Sent: Thursday, September 17, 2009 9:54 PM
Subject: What should happen with intermediate resource paths that end with "/"?


So if I have a '@Path("/catalog/")' on my class, and
'@Path("/item/{id}")' on a method of the class, what URL should be
matched by the method?  In my testing, it matches perfectly fine with
"/catalog/item/1".  However, when SoapUI loads the WADL file for this
project, it results in a path like "/catalog//item/1", which fails in my
service, of course.  When I then removed the trailing slashes from my
annotations and reran the test with SoapUI, it worked fine.

So, does JAX-RS specifically disallow trailing slashes, or does it
specify that tools should remove consecutive slashes when building URLs?

Reply via email to