You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@slider.apache.org by Steve Loughran <st...@hortonworks.com> on 2014/09/25 14:24:06 UTC

Important: jersey ignores @JsonProperty annotations

For anyone playing with REST resources in slider, know that the version of
Jersey we are using appears to ignore all @JsonProperty annotations

https://java.net/jira/browse/JERSEY-989

I found this as the registry entries were adding special "yarn:id" and
"yarn:persistence" attributes mapped to the fields "id" and "persistence"
... they weren't making it into the destination service class because they
were being published with the field, names, not the declared property names.

workaround: give the fields names like "yarn_id" and "yarn_persistence"


Scanning the code, the only JSON-marshalled classes that declare their json
property fields are the Agent ones ... most of which match their field
names completely.

some are case-different, e.g in
org.apache.slider.server.appmaster.web.rest.agent.HostInfo:


  @JsonProperty("uptime_hours")
  public long getUptimeHours() {
    return this.uptime_hours;
  }

  @JsonProperty("uptime_hours")
  public void setUpTimeHours(long uptime_hours) {
    this.uptime_hours = uptime_hours;
  }

  @JsonProperty("uptime_days")
  public long getUpTimeDays() {
    return this.uptime_days;
  }

  @JsonProperty("uptime_days")
  public void setUpTimeDays(long

This may work for the agent POSTing data to the AM, as it is not Jersey
itself publishing it —but if the AM did ever try to serve the same data up
on its REST endpoints, *the fields would not be marshalled correctly*.

I've created SLIDER-454 to handle the agent code, but everyone needs to be
aware of it and to not try to use different names for properties than the
java fields.

-Steve




-steve

-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.

Re: Important: jersey ignores @JsonProperty annotations

Posted by Steve Loughran <st...@hortonworks.com>.
do they work? As https://issues.apache.org/jira/browse/HBASE-12099 shows
problems there

On 25 September 2014 15:07, Billie Rinaldi <bi...@gmail.com> wrote:

> Another possible workaround may be to use jaxb annotations like
> @XmlElement(name = "uptime_hours").
>
> On Thu, Sep 25, 2014 at 5:24 AM, Steve Loughran <st...@hortonworks.com>
> wrote:
>
> > For anyone playing with REST resources in slider, know that the version
> of
> > Jersey we are using appears to ignore all @JsonProperty annotations
> >
> > https://java.net/jira/browse/JERSEY-989
> >
> > I found this as the registry entries were adding special "yarn:id" and
> > "yarn:persistence" attributes mapped to the fields "id" and "persistence"
> > ... they weren't making it into the destination service class because
> they
> > were being published with the field, names, not the declared property
> > names.
> >
> > workaround: give the fields names like "yarn_id" and "yarn_persistence"
> >
> >
> > Scanning the code, the only JSON-marshalled classes that declare their
> json
> > property fields are the Agent ones ... most of which match their field
> > names completely.
> >
> > some are case-different, e.g in
> > org.apache.slider.server.appmaster.web.rest.agent.HostInfo:
> >
> >
> >   @JsonProperty("uptime_hours")
> >   public long getUptimeHours() {
> >     return this.uptime_hours;
> >   }
> >
> >   @JsonProperty("uptime_hours")
> >   public void setUpTimeHours(long uptime_hours) {
> >     this.uptime_hours = uptime_hours;
> >   }
> >
> >   @JsonProperty("uptime_days")
> >   public long getUpTimeDays() {
> >     return this.uptime_days;
> >   }
> >
> >   @JsonProperty("uptime_days")
> >   public void setUpTimeDays(long
> >
> > This may work for the agent POSTing data to the AM, as it is not Jersey
> > itself publishing it —but if the AM did ever try to serve the same data
> up
> > on its REST endpoints, *the fields would not be marshalled correctly*.
> >
> > I've created SLIDER-454 to handle the agent code, but everyone needs to
> be
> > aware of it and to not try to use different names for properties than the
> > java fields.
> >
> > -Steve
> >
> >
> >
> >
> > -steve
> >
> > --
> > CONFIDENTIALITY NOTICE
> > NOTICE: This message is intended for the use of the individual or entity
> to
> > which it is addressed and may contain information that is confidential,
> > privileged and exempt from disclosure under applicable law. If the reader
> > of this message is not the intended recipient, you are hereby notified
> that
> > any printing, copying, dissemination, distribution, disclosure or
> > forwarding of this communication is strictly prohibited. If you have
> > received this communication in error, please contact the sender
> immediately
> > and delete it from your system. Thank You.
> >
>

-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.

Re: Important: jersey ignores @JsonProperty annotations

Posted by Billie Rinaldi <bi...@gmail.com>.
Another possible workaround may be to use jaxb annotations like
@XmlElement(name = "uptime_hours").

On Thu, Sep 25, 2014 at 5:24 AM, Steve Loughran <st...@hortonworks.com>
wrote:

> For anyone playing with REST resources in slider, know that the version of
> Jersey we are using appears to ignore all @JsonProperty annotations
>
> https://java.net/jira/browse/JERSEY-989
>
> I found this as the registry entries were adding special "yarn:id" and
> "yarn:persistence" attributes mapped to the fields "id" and "persistence"
> ... they weren't making it into the destination service class because they
> were being published with the field, names, not the declared property
> names.
>
> workaround: give the fields names like "yarn_id" and "yarn_persistence"
>
>
> Scanning the code, the only JSON-marshalled classes that declare their json
> property fields are the Agent ones ... most of which match their field
> names completely.
>
> some are case-different, e.g in
> org.apache.slider.server.appmaster.web.rest.agent.HostInfo:
>
>
>   @JsonProperty("uptime_hours")
>   public long getUptimeHours() {
>     return this.uptime_hours;
>   }
>
>   @JsonProperty("uptime_hours")
>   public void setUpTimeHours(long uptime_hours) {
>     this.uptime_hours = uptime_hours;
>   }
>
>   @JsonProperty("uptime_days")
>   public long getUpTimeDays() {
>     return this.uptime_days;
>   }
>
>   @JsonProperty("uptime_days")
>   public void setUpTimeDays(long
>
> This may work for the agent POSTing data to the AM, as it is not Jersey
> itself publishing it —but if the AM did ever try to serve the same data up
> on its REST endpoints, *the fields would not be marshalled correctly*.
>
> I've created SLIDER-454 to handle the agent code, but everyone needs to be
> aware of it and to not try to use different names for properties than the
> java fields.
>
> -Steve
>
>
>
>
> -steve
>
> --
> CONFIDENTIALITY NOTICE
> NOTICE: This message is intended for the use of the individual or entity to
> which it is addressed and may contain information that is confidential,
> privileged and exempt from disclosure under applicable law. If the reader
> of this message is not the intended recipient, you are hereby notified that
> any printing, copying, dissemination, distribution, disclosure or
> forwarding of this communication is strictly prohibited. If you have
> received this communication in error, please contact the sender immediately
> and delete it from your system. Thank You.
>

Re: Important: jersey ignores @JsonProperty annotations

Posted by Steve Loughran <st...@hortonworks.com>.
I'm tempted to stick with the versions in Hadoop if we can avoid classpath
complexity, but they have issues there/

On 25 September 2014 14:43, Ted Yu <yu...@gmail.com> wrote:

> Should we upgrade to 1.17 or newer version ?
>
> Cheers
>
> On Sep 25, 2014, at 5:24 AM, Steve Loughran <st...@hortonworks.com>
> wrote:
>
> > For anyone playing with REST resources in slider, know that the version
> of
> > Jersey we are using appears to ignore all @JsonProperty annotations
> >
> > https://java.net/jira/browse/JERSEY-989
> >
> > I found this as the registry entries were adding special "yarn:id" and
> > "yarn:persistence" attributes mapped to the fields "id" and "persistence"
> > ... they weren't making it into the destination service class because
> they
> > were being published with the field, names, not the declared property
> names.
> >
> > workaround: give the fields names like "yarn_id" and "yarn_persistence"
> >
> >
> > Scanning the code, the only JSON-marshalled classes that declare their
> json
> > property fields are the Agent ones ... most of which match their field
> > names completely.
> >
> > some are case-different, e.g in
> > org.apache.slider.server.appmaster.web.rest.agent.HostInfo:
> >
> >
> >  @JsonProperty("uptime_hours")
> >  public long getUptimeHours() {
> >    return this.uptime_hours;
> >  }
> >
> >  @JsonProperty("uptime_hours")
> >  public void setUpTimeHours(long uptime_hours) {
> >    this.uptime_hours = uptime_hours;
> >  }
> >
> >  @JsonProperty("uptime_days")
> >  public long getUpTimeDays() {
> >    return this.uptime_days;
> >  }
> >
> >  @JsonProperty("uptime_days")
> >  public void setUpTimeDays(long
> >
> > This may work for the agent POSTing data to the AM, as it is not Jersey
> > itself publishing it —but if the AM did ever try to serve the same data
> up
> > on its REST endpoints, *the fields would not be marshalled correctly*.
> >
> > I've created SLIDER-454 to handle the agent code, but everyone needs to
> be
> > aware of it and to not try to use different names for properties than the
> > java fields.
> >
> > -Steve
> >
> >
> >
> >
> > -steve
> >
> > --
> > CONFIDENTIALITY NOTICE
> > NOTICE: This message is intended for the use of the individual or entity
> to
> > which it is addressed and may contain information that is confidential,
> > privileged and exempt from disclosure under applicable law. If the reader
> > of this message is not the intended recipient, you are hereby notified
> that
> > any printing, copying, dissemination, distribution, disclosure or
> > forwarding of this communication is strictly prohibited. If you have
> > received this communication in error, please contact the sender
> immediately
> > and delete it from your system. Thank You.
>

-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.

Re: Important: jersey ignores @JsonProperty annotations

Posted by Ted Yu <yu...@gmail.com>.
Should we upgrade to 1.17 or newer version ?

Cheers

On Sep 25, 2014, at 5:24 AM, Steve Loughran <st...@hortonworks.com> wrote:

> For anyone playing with REST resources in slider, know that the version of
> Jersey we are using appears to ignore all @JsonProperty annotations
> 
> https://java.net/jira/browse/JERSEY-989
> 
> I found this as the registry entries were adding special "yarn:id" and
> "yarn:persistence" attributes mapped to the fields "id" and "persistence"
> ... they weren't making it into the destination service class because they
> were being published with the field, names, not the declared property names.
> 
> workaround: give the fields names like "yarn_id" and "yarn_persistence"
> 
> 
> Scanning the code, the only JSON-marshalled classes that declare their json
> property fields are the Agent ones ... most of which match their field
> names completely.
> 
> some are case-different, e.g in
> org.apache.slider.server.appmaster.web.rest.agent.HostInfo:
> 
> 
>  @JsonProperty("uptime_hours")
>  public long getUptimeHours() {
>    return this.uptime_hours;
>  }
> 
>  @JsonProperty("uptime_hours")
>  public void setUpTimeHours(long uptime_hours) {
>    this.uptime_hours = uptime_hours;
>  }
> 
>  @JsonProperty("uptime_days")
>  public long getUpTimeDays() {
>    return this.uptime_days;
>  }
> 
>  @JsonProperty("uptime_days")
>  public void setUpTimeDays(long
> 
> This may work for the agent POSTing data to the AM, as it is not Jersey
> itself publishing it —but if the AM did ever try to serve the same data up
> on its REST endpoints, *the fields would not be marshalled correctly*.
> 
> I've created SLIDER-454 to handle the agent code, but everyone needs to be
> aware of it and to not try to use different names for properties than the
> java fields.
> 
> -Steve
> 
> 
> 
> 
> -steve
> 
> -- 
> CONFIDENTIALITY NOTICE
> NOTICE: This message is intended for the use of the individual or entity to 
> which it is addressed and may contain information that is confidential, 
> privileged and exempt from disclosure under applicable law. If the reader 
> of this message is not the intended recipient, you are hereby notified that 
> any printing, copying, dissemination, distribution, disclosure or 
> forwarding of this communication is strictly prohibited. If you have 
> received this communication in error, please contact the sender immediately 
> and delete it from your system. Thank You.