Naresh,
Yes you seem to be pointing in the right direction.
To start with, the pet catalog app does not have any class with a @Provider
annotation
also, my logs are:
---------------------------------------------------------------------------------
etc etc
Scanning for root resource and provider classes in the paths:
/Users/gautam/NetBeansProjects/catalogitem/build/web/WEB-INF/lib
/Users/gautam/NetBeansProjects/catalogitem/build/web/WEB-INF/classes
Root resource classes found:
class service.ItemsResource
Provider classes found:
---------------------------------------------------------------------------------
There is no Provider class listed after the statement "Provider classes
found" and I was finding this weird as to why nothing is displayed after
that line.
This is as per the code available at:
https://techdayscode.dev.java.net/files/documents/7105/106278/catalog.zip
for the RESTful Pet Catalog app:
http://weblogs.java.net/blog/caroljmcdonald/archive/2008/08/a_restful_pet_c_1.html
To get the project to this state, all one has to do is:
1. Generate Entity classes from database (Table Item or anything else)
2. Generate Restful Web Services from Entity classes
The "Example JSON Data" section of this tutorial does seem to show that the
"items" element should be generated and mentions nothing about a @Provider
annotation.
Could you suggest any more investigative steps or have a look at the code in
the above link.
Thanks,
Gautam
Srinivas Naresh Bhimisetty wrote:
>
> Hi Gautam,
>
> I doubt if your Provider class is being detected or not, are you able
> to see some message like:
>
> ------------------------------------------------------------
> INFO: Provider classes found:
> class /yourContextResolver
> -------------------------------------------------------------
>
> /in the logs.
>
> -Naresh
>
>
> Gautam Arora wrote:
>> Hi Naresh,
>>
>> I set rootUnwrapping to false, but still same output as before i.e. root
>> element is dropped
>>
>> Let me know if you have any more ideas on what I could try, I'll try them
>> in
>> realtime (well, almost!) :)
>>
>> Thanks,
>> Gautam
>>
>>
>> Srinivas Naresh Bhimisetty wrote:
>>
>>> Hi Gautam,
>>>
>>> could you try setting rootUnwrapping to 'false' instead, i.e.,
>>>
>>> JAXBContext context = new
>>> JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(false).arrays("items").build(),type);
>>>
>>> Hope this helps,
>>> Naresh
>>>
>>>
>>>
>>> Gautam Arora wrote:
>>>
>>>> update:
>>>>
>>>> 1. I moved to Jersey 1.0.2 (downloaded it and added to netbeans)
>>>> 2. Edited the UriResolver.resolve() method
>>>> original: JAXBContext context = JAXBContext.newInstance(type);
>>>> modified: JAXBContext context = new
>>>> JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(true).arrays("items").build(),type);
>>>>
>>>> This was as per the steps given at
>>>> http://blogs.sun.com/japod/entry/configuring_json_for_restful_web
>>>>
>>>> But the root element is still getting dropped. Any tips on how to make
>>>> this
>>>> work with this app?
>>>>
>>>> Gautam
>>>>
>>>>
>>>> Gautam Arora wrote:
>>>>
>>>>
>>>>> Hi,
>>>>> I'm following the RESTful Pet Catalog tutorial from
>>>>> http://weblogs.java.net/blog/caroljmcdonald/archive/2008/08/a_restful_pet_c_1.html
>>>>>
>>>>> The expected JSON response (as per the tutorial is)
>>>>> http://localhost:8080/catalog/resources/items/
>>>>>
>>>>> {"items":{"@uri":"http://localhost:8080/catalog/resources/items","item":[{
>>>>> etc etc
>>>>>
>>>>> but I get the response as:
>>>>> {"@uri":"http://localhost:8080/catalog/resources/items","item":[{ etc
>>>>> etc
>>>>>
>>>>> The "items" label is dropped.
>>>>> I've read here on forum posts that say that dropping off the root
>>>>> element
>>>>> is a desired feature and with newer releases of jersey it should be
>>>>> fixed(/configurable?)
>>>>>
>>>>> I've developed the app myself and also tested the same app by
>>>>> downloading
>>>>> it and running it and and running into the same issue.
>>>>>
>>>>> I'm using Jersey 1.0. Is this issue fixed in 1.0.2?
>>>>>
>>>>> Whats the best way to make jersey1.0 generate the "items" label for
>>>>> this
>>>>> app? I've read on posts that we need to add a property for the json
>>>>> unwrapping but cant figure out where/how to put it in the pet catalog
>>>>> sample app.
>>>>>
>>>>> I need this as I'm using YUI which expects this and throws an invalid
>>>>> label error otherwise
>>>>> As per the tutorial, having the label is the expected behavior, so any
>>>>> reasons why I could be missing it?
>>>>>
>>>>> Thanks,
>>>>> Gautam
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
>
--
View this message in context: http://n2.nabble.com/JSON-Arrays-issue-in-Pet-Catalog-sample-app-tp2406690p2408178.html
Sent from the Jersey mailing list archive at Nabble.com.