users@jersey.java.net

[Jersey] Re: Howto enable JSON support for Jersey2 in Glassfish?

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Sat, 26 Jan 2013 23:12:43 +0100

Arul,

thanks a lot.

Doh - I totally forgot that I have to *extend* Application. I was looking for a method to call ... that hurts ;-)

Jan

On 26.01.2013, at 22:19, Arul Dhesiaseelan <aruld_at_acm.org> wrote:

> Hi Jan,
>
> You can enable Jackson/Jettison feature on the server-side by registering features in the JAX-RS application. No web.xml required. Here is an example.
>
> @ApplicationPath("/")
> public class MyApplication extends Application {
>
> @Override
> public Set<Class<?>> getClasses() {
> final Set<Class<?>> classes = new HashSet<Class<?>>();
> classes.add(ClusterResource.class);
> return classes;
> }
>
> @Override
> public Set<Object> getSingletons() {
> final Set<Object> instances = new HashSet<Object>();
> instances.add(new JacksonFeature());
> instances.add(new LoggingFilter());
> return instances;
> }
> }
>
> GF4 bundles Jersey 2 m11, so you should be good to go. I put together a simple project that shows this end-to-end running on GlassFish 4 b72 [1].
>
>
> -Arul
>
> [1] https://github.com/aruld/jersey2-sample
>
>
> On Fri, Jan 25, 2013 at 11:40 PM, Jan Algermissen <jan.algermissen_at_nordsc.com> wrote:
> Hi,
>
> I am feeling kinda like an idiot to ask this, but...
>
> how do I enable JSON (JAXB serialisation) for Jersey 2 in Glassfish?
>
> Building with maven; preferably not having a web.xml.
>
> Jan
>