users@jersey.java.net

Re: [Jersey] no-arg constructors (probably JAXB-related)

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Wed, 28 Oct 2009 19:08:04 -0700

On Wed, Oct 28, 2009 at 7:16 AM, Zoltan Arnold NAGY <Zoltan.Nagy_at_sun.com> wrote:
> Hi,
>
> Let's say I have an immutable class Data, which is returned (as a JSON) by a
> webservice
> method.
> Why is it a requirement to have a no-arg constructor for classes used
> together with JAXB?
>
> The client application is multi-threaded, so I'd prefer to use immutable
> classes and as I already
> have a shared jar containing shared classes across multiple programs, I'd
> like to reuse it.
>
> Is there something I could do?

JAXB does require this to be able to easily instantiate values.

If you don't mind using Jackson JAX-RS provider, it can actually use
constructors (with version 1.2), see
[http://www.cowtowncoder.com/blog/archives/2009/07/entry_303.html] or
[http://wiki.fasterxml.com/JacksonFeatureCreators] for details.

-+ Tatu +-