users@jersey.java.net

Re: [Jersey] Conflict when using Jersey and Jackson json

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 16 Apr 2010 12:09:50 +0200

Hi Franz,

Can you send a running test case (preferably a maven project) that way
it will be easier to investigate.

This type of error is often indicative of compiling against one
version while running against another version.

Paul.

On Apr 16, 2010, at 5:10 AM, Franz Wong wrote:

> Hi,
>
> I made a webapp using Jersey. After that, I wrote unit tests for it.
> The test data is in json format and parsed by jackson json. The
> object will be input to the business layer class for test. Every
> time I run it, error occurred.
>
> Later, I created a simple project with only an entity class and a
> unit test class. When I just included the jackson json dependency in
> maven, everything run smoothly. However, when I added jersey
> dependency, the same error occurred.
>
> Originally, I would like to use the jersey built-in json support for
> my unit test. Since my test is not at service layer, I cannot get
> the Providers instance, hence I cannot get the MessageBodyReader
> instance.
>
> Thanks.
> Franz
>
> the error :
>
> java.lang.VerifyError: (class: org/codehaus/jackson/map/
> ObjectMapper, method: writeValueAsBytes signature: (Ljava/lang/
> Object;)[B) Incompatible argument to function
>
> my test :
>
> ObjectMapper objMapper = new ObjectMapper();
> User user = (User) objMapper.readValue("{\"name\" : \"franzwong\",
> \"itemList\" : [\"apple\", \"orange\"]}", User.class);
> Assert.assertEquals("franzwong", user.getName());