users@jersey.java.net

Re: [Jersey] Trouble accessing resource

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 24 Mar 2009 09:58:15 +0100

Hi Rod,

This is indeed perplexing. It sounds like an issue with Tomcat on
reloading.


On Mar 23, 2009, at 9:59 PM, Rod Fitzsimmons Frey wrote:

> I don't even know how to correctly frame this question, so I'm
> hoping somebody has seen a similar symptom and can point me in the
> right direction. Failing that, a pointer or two on how to debug
> would be greatly appreciated.
>
> I have a simple resource for accessing and creating users.
> UsersResource has a post method:
>
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/xml")
> public Response post(@FormParam("email") String email,
> @FormParam("password") String password) {
> log.log(Level.INFO, "Creating a user: " + email);
> ..etc
>
> Here's the issue: when I deploy this class and call the POST with a
> curl command, it gets called... until I restart the server. Then
> the call returns a 201 Created, but my class doesn't get called.

How are you verifying that? debugging or print statements?

What is the response from your resource when you used curl a 200 or a
201?


> I can get it to go again by modifying the size of the
> UsersResources.class file (just a touch doesn't work): then it will
> get called successfully again until I restart the server.
>
> A filter I have in place is getting called consistently in both cases.
>
> I'm running Jersey bundle 1.0 on Tomcat 6.0.18.
>
> AFAIK the default return value should be a 401 if Jersey isn't
> finding a resource class,

404.


> or 204 No Content for null content.

Only if a resource method of a resource class returns null content.


> I'm getting neither of those, rather a 201.

Can you send the complete code for your post method?


> Plus that log statement in the first line of the post method is
> never called.
>
> I'm truly perplexed. Any hints?
>

This is a completely wild guess: do you have logging configuring in
Tomcat?

There was a bug with Jersey 1.0.1 whereby if Tomcat values or servlet
filters accessed the request parameters Jersey could not get the form
parameters, they would be null. This is fixed in Jersey 1.0.2. But i
am not sure that is the cause of your problem because it works before
you perform a restart.

Paul.