users@jersey.java.net

Re: [Jersey] _at_Path

From: Imran M Yousuf <imyousuf_at_smartitengineering.com>
Date: Tue, 12 Oct 2010 13:01:16 +0600

Hi Hilco,

If one uses @Path(SOME_PATH) on a class Jersey identifies it as root
resource and no two root resource can have the same path.
https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#d0e196

I would go about using sub-resources on the server side in cases as
that of yours -
https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#d0e770

I hope that helps.

Regards,

Imran

On Sat, Oct 9, 2010 at 1:19 AM, Hilco Wijbenga <hilco.wijbenga_at_gmail.com> wrote:
> Hi all,
>
> I'm using Jersey 1.4.
>
> I guess I'm misunderstanding how @Path works.
>
> If I try
>
> @Path("/")
> class AccountResource {
>  @GET
>  @Path("/account/{id}")
>  public ... get(...) {...}
>
>  @POST
>  @Path("/accounts")
>  public ... post(...) {...}
> }
>
> @Path("/")
> class UserResource {
>  @GET
>  @Path("/user/{id}")
>  public ... get(...) {...}
>
>  @POST
>  @Path("/users")
>  public ... post(...) {...}
> }
>
> I get
>
> 8-Oct-2010 10:55:52 AM
> com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
> INFO: Initiating Jersey application, version 'Jersey: 1.4 09/11/2010 10:30 PM'
> 8-Oct-2010 10:55:52 AM com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Scanning for root resource and provider classes in the packages:
>  com.xyz
>  org.codehaus.jackson.jaxrs
> 8-Oct-2010 10:55:52 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
> INFO: Root resource classes found:
>  class com.xyz.UserResource
>  class com.xyz.AccountResource
> 8-Oct-2010 10:55:52 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
> INFO: Provider classes found:
>  class org.codehaus.jackson.jaxrs.JacksonJsonProvider
> 8-Oct-2010 10:55:52 AM
> com.sun.jersey.server.impl.application.DeferredResourceConfig$ApplicationHolder
> <init>
> INFO: Instantiated the Application class com.xyz.RestApplication
> 8-Oct-2010 10:55:53 AM com.sun.jersey.spi.inject.Errors processErrorMessages
> SEVERE: The following errors and warnings have been detected with
> resource and/or provider classes:
>  SEVERE: Conflicting URI templates. The URI template / for root
> resource class com.xyz.AccountResource and the URI template /
> transform to the same regular expression (/.*)?
>
> Why? Each of AccountResource.get()/post() and
> UserResource.get()/post() have a unique URL, don't they? What's the
> problem?
>
> Cheers,
> Hilco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
Imran M Yousuf
Entrepreneur & CEO
Smart IT Engineering Ltd.
25/5B, Block F, Haji Chinu Miah Road Bylane
Joint Quarter, Mohammadpur
Dhaka - 1207, Bangladesh
Email: imran_at_smartitengineering.com
Twitter: @imyousuf - http://twitter.com/imyousuf
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557