users@jersey.java.net

[Jersey] Re: Unable to get simple JAXB to work

From: Sean Landis <sean.landis_at_gmail.com>
Date: Thu, 7 Apr 2011 11:29:17 -0600

Hi Jakub,

Here's curl:

c1inf-lm20553:messageData slandis$ curl -i --header "Content-Type:
application/xml" --upload-file newuser.jaxb
http://localhost:9998/weblogs/joe
HTTP/1.1 400 Bad Request
server: grizzly/1.9.18
Transfer-Encoding: chunked
Date: Thu, 07 Apr 2011 17:27:05 GMT
Connection: close


So it doesn't like the request but I can't see what's wrong here.
If the request made it to the resource, then the call to
createWeblog() would print out "Joe Blow".

Sean

On Thu, Apr 7, 2011 at 11:18 AM, Jakub Podlesak
<jakub.podlesak_at_oracle.com> wrote:
> Hi Sean,
>
> the info message only tells you no provider was found within
> your application. I.e. you should not bother with that informational
> message, as long as you do not get any stack trace/error message.
>
> What does curl return, if you call it with the -i option?
>
> How did you check, the request did not make it to the resource?
>
> ~Jakub
>
> On 04/07/2011 06:39 PM, sean.landis_at_gmail.com wrote:
>>
>> HI,
>> I am trying to get JAXB to work with a simple resource:
>>
>> ...
>>   @PUT @Path("{user}")
>>   @Consumes(MediaType.APPLICATION_XML)
>>   public void createWeblog(@PathParam("user") String user, User
>> userData) {
>>     Bordello.get(WeblogsService.class).createWeblog(user, userData);
>>   }
>>
>> I am using Grizzly container. My curl command is:
>> curl --header "Content-Type: application/xml" --upload-file
>> newuser.jaxb http://localhost:9998/weblogs/joe
>>
>> and newuser.jaxb is:
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <User>
>>   <name>
>>   Joe Blow
>>   </name>
>> </User>
>>
>> The JAXB entity is:
>>
>> @XmlRootElement
>> public class User {
>>   private String name;
>>
>>   public User() {}
>>   public User(String name) { setName(name); }
>>   public String getName() { return name; }
>>   public void setName(String name) { this.name = name; }
>> }
>>
>> When I send the PUT request to the server I get the following:
>>
>> Apr 7, 2011 10:26:27 AM com.sun.jersey.api.core.PackagesResourceConfig
>> init
>> INFO: Scanning for root resource and provider classes in the packages:
>>   com.overstock.rest
>>   com.overstock.model
>> Apr 7, 2011 10:26:27 AM com.sun.jersey.api.core.ScanningResourceConfig
>> logClasses
>> INFO: Root resource classes found:
>>   class com.overstock.rest.MyResource
>>   class com.overstock.rest.WeblogsResource
>> Apr 7, 2011 10:26:27 AM com.sun.jersey.api.core.ScanningResourceConfig
>> init
>> INFO: No provider classes found.
>> Apr 7, 2011 10:26:27 AM
>> com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
>> INFO: Initiating Jersey application, version 'Jersey: 1.6 03/25/2011
>> 01:14 PM'
>>
>>
>> I don't know how to configure the provider. Please help!
>>
>
>