On Mar 24, 2009, at 1:45 PM, Rod Fitzsimmons Frey wrote:
> Thanks for the reply, Paul. To answer your questions: I'm using
> default Tomcat logging, whatever comes out of the box. I'm just
> accessing commons logging. Newb question: is there some way to turn
> on detailed logging within Jersey so I can see what class is
> returning the 201?
Unfortunately not.
I presume that you have installed your app that the 201 is actually
being returned from the UsersResource if you are using the same
request URL.
How are you mapping your exceptions?
>
>
> The response from the curl is a 201:
>
> rod-fitzsimmons-freys-macbook-pro:~ Rod$ curl -d
> "email=test3@here.com&password=test" -H "Accept:application/xml" http://dev.attassa.com/ws/users
> -i
> HTTP/1.1 201 Created
> Server: Apache-Coyote/1.1
> Content-Type: application/xml
> Content-Length: 0
> Date: Tue, 24 Mar 2009 12:47:17 GMT
>
After after you do a reload?
Paul.
> I'll make sure I have 1.0.2 installed and that there are no other
> jars lurking on the classpath somewhere.
>
> Here's the complete post method:
>
>
> @Path("/users")
> public class UsersResource {
>
> @Context
> private UriInfo context;
> @Context
> private HttpServletRequest hsr;
>
> ... etc
>
> @POST
> @Consumes("application/x-www-form-urlencoded")
> @Produces("application/xml")
> public Response post(@FormParam("email") String email,
> @FormParam("password") String password)
> throws MissingParameterException, UserExistsException,
> AttassaServerException {
> log.log(Level.INFO, "Creating a user: " + email);
> if (email == null || email.trim().length() == 0 || password
> == null || password.trim().length() == 0) {
> throw new MissingParameterException();
> }
> User u = null;
> try {
> if (userDAO.findUserByEmail(email) != null) {
> System.out.println("UsersResource: Found the user
> already!!");
> throw new UserExistsException();
> }
> System.out.println("UsersResource: Creating the user.
> userDAO is " + userDAO);
> u = userDAO.createNewUser(email, password, true);
> } catch (java.sql.SQLException ex) {
> ex.printStackTrace();
> throw new AttassaServerException(ex);
> }
> System.out.println("UsersResource: Created a user. User is
> " + u.getEmail());
>
> String clientguid = hsr.getHeader("X-Attassa-ClientID");
> String agent = hsr.getHeader("User-Agent");
> userDAO.updateClientInstall(clientguid, "usercreate",
> u.getDbId(), agent, "");
> return
> Response.status(Response.Status.CREATED).entity(u).build();
> }
>
>
>
> On 24-Mar-09, at 2:58 AM, Paul Sandoz wrote:
>
>> 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.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>