users@jersey.java.net

[Jersey] Re: Migrating from 1.17 to 2.x

From: michal sankot <michalsankot_at_appnostic.com>
Date: Tue, 11 Mar 2014 13:43:58 +0100

hi jakub,
thanks for pointing me to the section about jackson dependency.

nonetheless, it's still not very clear to me how to migrate my pom
(build.gradle actually, but syntax doesn't matter). currently it
contains this:

     // Jersey REST services deps
     compile group: 'com.sun.jersey', name:'jersey-core', version: '1.17'
     compile group: 'com.sun.jersey', name:'jersey-client', version: '1.17'
     compile group: 'com.sun.jersey', name:'jersey-json', version: '1.17'
     compile group: 'com.sun.jersey', name:'jersey-servlet', version: '1.17'

     // Jersey server depends on asm3.3.1 while GAE depends on asm4.0.
     // When deployed to GAE, IncompatibleClassChangeError is thrown cause
     // Jersey can't work with asm4.0
     compile files("$libDir/jersey-server-1.17r.jar")
     compile files("$libDir/asm-3.3.1r.jar")

and my web.xml is

     <servlet>
         <servlet-name>REST handling</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
         <init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.app.project.controller</param-value>
         </init-param>
         <init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
             <param-value>true</param-value>
         </init-param>
         <!--DisableWADL needed so that it runs on GAE - it banes
reflection-->
         <init-param>
<param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
             <param-value>true</param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
     <servlet-mapping>
         <servlet-name>REST handling</servlet-name>
         <url-pattern>/rest/*</url-pattern>
     </servlet-mapping>

does web.xml change too ? i didn't really get it from the doc ;)

thanks,
michal


Dne 11. 3. 2014 10:17, Jakub Podlesak napsal(a):
> Hi Michal,
>
> Please see inline…
>
> On 06 Mar 2014, at 14:08, michal sankot <michalsankot_at_appnostic.com
> <mailto:michalsankot_at_appnostic.com>> wrote:
>
>> Hi guys,
>> I have a project with Jersey 1.17. It runs on Google App Engine and
>> we use it for consuming and producing XML and JSON over GET/POST.
>> Project is built with Gradle.
>>
>> I'm thinking about migrating it to Jersey 2.x. I have two questions:
>>
>> 1) Are those features that I use in 1.17 available in 2.x ?
>
> Yes, producing/consuming JSON/XML over GET/POST is supported.
>
>> 2) Which dependencies to use in 2.x ?
>
> It depends on you current 1.17 config. POJOMappingFeature uses Jacskon
> JSON providers.
> Please see
> https://jersey.java.net/documentation/latest/media.html#json.jackson on how
> to use them in Jersey 2.
>
> HTH,
>
> ~Jakub
>
>> There is a doc about migrating
>> (https://jersey.java.net/documentation/latest/migration.html) but it
>> doesn't address this issue of dependency migration. Furthermore how
>> do properties from web.xml change ? (like
>> com.sun.jersey.api.json.POJOMappingFeature etc.)
>>
>> Cheers,
>> Michal
>