You can find an example in svn:
http://java.net/projects/jersey/sources/code/show/examples/json-jackson
But, here is a simplified version for your case:
https://gist.github.com/1904116
You just need to toss in a JsonPojoMapper and configure it in the client.
See the gist for usage.
On Fri, Feb 24, 2012 at 11:15 AM, Jason Lee <jason.d.lee_at_oracle.com> wrote:
> I started a new project, and copied over my source, then built a POM that
> mirrors, as best as I can tell, the examples POM, taking inheritance into
> account, and lo and behold it works! :) If I have time, I'll compare the
> new POM with my old one to see what the difference is. Thanks for the help.
>
> I do have another question, though. I'm currently using POJO Mapping, as
> it was called in 1.2 on the server side. With 2.0, it appears that I have
> to add the JacksonJsonModule:
>
> ResourceConfig resourceConfig = ResourceConfig.builder().**addModules(new
> JsonJacksonModule())...
>
> I have that working, I think. I can request the resource, and I get a
> JSON string back. What I haven't been able to figure out is how to make
> the client do the same thing. That is, under 1.2, I could do something
> like this:
>
> ClientConfig clientConfig = new DefaultClientConfig();
> clientConfig.getFeatures().**put(JSONConfiguration.FEATURE_**POJO_MAPPING,
> Boolean.TRUE);
> client = Client.create(clientConfig);
> Cluster cluster = resource
> .path("cluster")
> .path(name)
> .accept(MIME_TYPE)
> .get(Cluster.class);
>
> and get a live, usable Cluster object to work with. I haven't been able
> to find any examples of how to do that with the JAX-RS 2.0 client API. Can
> you point me to an example of where that's done?
>
> Many thanks! :)
>
>
>
> On 2/24/12 4:09 AM, Marek Potociar wrote:
>
>> The things should work as described by Arul. Look at a pom.xml in any
>> of the new Jersey examples and make sure you have all the dependencies.
>> And if it still doesn't work, please open a Jira issue and attach your
>> project to it so that we can have a look.
>>
>> Marek
>>
>> On Fri 24 Feb 2012 06:39:31 AM CET, Jason Lee wrote:
>>
>>> I actually do have that. :| Maybe things will make more sense in the
>>> morning. Give it another stare with fresh eyes.
>>> If that doesn't work, I'll try rebuilding the project step by step.
>>> It's a simple POC, so that won't be a big deal.
>>>
>>> On 2/23/12 6:10 PM, Arul Dhesiaseelan wrote:
>>>
>>>> I suspect you may be missing provider bundle. Did you include the test
>>>> framework providers artifact in your POM?
>>>>
>>>> <dependency>
>>>> <groupId>org.glassfish.jersey.**test-framework.providers</*
>>>> *groupId>
>>>> <artifactId>jersey-test-**framework-provider-bundle</**
>>>> artifactId>
>>>> <version>2.0-m01</version>
>>>> <type>pom</type>
>>>> <scope>test</scope>
>>>> </dependency>
>>>>
>>>> It looks like you need to add this artifact in addition to your test
>>>> container. I used grizzly along with the above
>>>> artifact and it worked.
>>>>
>>>> -Arul
>>>>
>>>> On Thu, Feb 23, 2012 at 1:16 PM, Jason Lee<jason.d.lee_at_oracle.com<**
>>>> mailto:jason.d.lee_at_oracle.com>**> wrote:
>>>>
>>>> I'm trying to migrate a very simple test to Jersey 2.0 and having a
>>>> bit of a problem, namely, the test container
>>>> is not seeing my resource. Here's the resource source, more or
>>>> less:
>>>>
>>>> @Path("foo")
>>>> public class MyResource {
>>>>
>>>> @GET
>>>> @Produces("text/plain")
>>>> public String argh() {
>>>> return "argh!";
>>>> }
>>>> // ...
>>>> }
>>>>
>>>> And here's my test:
>>>>
>>>> public class ServiceTest extends JerseyTest {
>>>> protected static final String MIME_TYPE =
>>>> MediaType.APPLICATION_JSON;
>>>> @Override
>>>> protected Application configure() {
>>>> enable(TestProperties.LOG_**TRAFFIC);
>>>> ResourceConfig resourceConfig =
>>>> ResourceConfig.builder().**addClasses(MyResource.class).**build();
>>>>
>>>> return Application.builder(**resourceConfig).build();
>>>> }
>>>> @Test
>>>> public void simpleTest() {
>>>> Response response = target().path("foo").request("**
>>>> text/plain").get();
>>>> assertEquals(200, response.getStatus());
>>>> }
>>>> }
>>>>
>>>> The request always returns a 404. I'm looking at
>>>> examples/helloworld/.../**HelloWorldTest.java, and as far as I
>>>> can tell, I'm doing exactly what it's doing (that test runs just
>>>> fine), but my resource is never found.
>>>>
>>>> Any ideas what I might be doing wrong?
>>>>
>>>> --
>>>> Jason Lee
>>>> Senior Member of Technical Staff
>>>> GlassFish Team
>>>>
>>>> Oracle Corporation
>>>> Phone +1 405-216-3193<tel:%2B1%20405-216-3193>
>>>> Blog http://blogs.steeplesoft.com
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://aruld.info
>>>> http://twitter.com/aruld
>>>>
>>>>
>>>>
>>> --
>>> Jason Lee
>>> Senior Member of Technical Staff
>>> GlassFish Team
>>>
>>> Oracle Corporation
>>> Phone +1 405-216-3193
>>> Blog http://blogs.steeplesoft.com
>>>
>>
>
> --
> Jason Lee
> Senior Member of Technical Staff
> GlassFish Team
>
> Oracle Corporation
> Phone +1 405-216-3193
> Blog http://blogs.steeplesoft.com
>
>