users@jersey.java.net

Re: [Jersey] Pluralization (again)

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 5 Aug 2010 10:28:08 +0200

Hi Chris,

You can set the following feature:

  https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/core/util/FeaturesAndProperties.html
#FEATURE_XMLROOTELEMENT_PROCESSING

In the servlet init params set the
"com.sun.jersey.config.feature.XmlRootElementProcessing" to "true".

The reason this is not set to true by default is because did not want
to break on the wire compatibility i.e. when we first implemented this
we forogot about the XmlRootElement :-(

Paul.

On Aug 3, 2010, at 9:31 PM, Christopher Piggott wrote:

>
> I just filed a bug against jaxb, but then my coworker reminded me
> that the pluralization was actually contributed to jersey, not
> jaxb ... so now I am thinking I made an error and that the bug is
> actually in jersey. If someone can confirm, then I'll go ahead and
> write it as a low priority bug in jersey (then someone else can
> decide if it's actually a "feature", haha).
>
> https://jaxb.dev.java.net/issues/show_bug.cgi?id=785
>
> The gist is this:
>
> @XmlRootElement(name="segment")
> public class SegmentBean {
> ...
> }
>
> @Resource
> @RequestScoped
> @Path("/latest")
> public class SegmentResource {
> @GET
> @Produces("application/xml")
> public List<SegmentBean> getLatest() { ... }
> }
>
>
> Because I named the root element "segment" (not "SegmentBean") I
> expected to get this out as the list:
>
>
> <segments>
>
> <segment/>
> </segments>
>
>
> Instead what I got out was:
>
>
> <segmentBeans>
>
> <segment/>
> </segmentBeans>
>
>
> This is with jersey 1.3 and jaxb 2.1.10
>
>
> Would somebody help me resolve 1. is this really a problem and 2. is
> it the jersey contrib that'st he problem (ignoring the
> XmlRootElement's "name" property) or is it actually back in jaxb
> somewhere?
>
>
> --Chris
>
>
>