users@jersey.java.net

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

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Fri, 08 Apr 2011 16:22:56 +0200

Hi Sean,

The response is coming from Grizzly, not Jersey,
i.e. the request even does not make it to the Jersey runtime.
I don't know what could be wrong... Any suspicious log message?

You may try to introduce a simple get method
on the resource to make sure, you have the url right...

Another thing is the curl syntax. Your command should work,
byt anyway, i use a slightly different syntax:

curl -i -XPUT -HContent-type:application/xml --data '<xml>data</xml>' $uri

Does any of the above help?

~Jakub

P.S. [1] includes quite a complex example of JAXB support in Jersey. You
might
want to check it out.

[1]http://download.java.net/maven/2/com/sun/jersey/samples/jaxb/1.6/jaxb-1.6-project.zip

On 04/07/2011 07:29 PM, Sean Landis wrote:
> 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!
>>>
>>