Hi,
So I added the @JsonProperty to the getter and the declaration of the element, and it works now. It used to work with the previous version of Jersey and Jackson, without those additional places being annotated. - Pritam
On Tuesday, March 24, 2015 11:01 AM, Pritam Moodbidri <pritam_at_yahoo-inc.com> wrote:
Hi Jakub
The bean looks like this
@JsonInclude(Include.NON_NULL)@XmlRootElement(name = "MyBean")@MailBean_at_JsonIgnoreProperties(ignoreUnknown = true)public class MyBean { private List<MyElement> myElements;
@XmlElement public List<MyElement> getMyElements() { return myElements; }
@JsonProperty(“my_elements") public void setMyElements(final List<MyElement> elements) { this.myElements = elements; }}
And, I get the exception when I have a
final String requestJson = mapper.writeValueAsString(request);
(request is a MyBean object)
Thanks
- Pritam
On Tuesday, March 24, 2015 10:33 AM, Jakub Podlesak <jakub.podlesak_at_oracle.com> wrote:
Hi Pritam,
Not sure. Would you mind sharing a bit more information on your bean and your method?Source code snippet will work best.
Have you tried to ask at the Jacskon forum,
http://jackson-users.ning.com/forum?
Cheers,
~Jakub
On 24 Mar 2015, at 18:17, Pritam Moodbidri <pritam_at_yahoo-inc.com> wrote:
Hi,
I am upgrading Jersey from 2.7 to 2.17, and also relatively Jackson from 1.x to 2.x.
One of the function was using ObjectMapper.writeValueAsString, and using the bean as an argument. The bean is using @JsonProperty for an element in it, which has a different name, than the element variable name, which is throwing the exception
java.lang.IllegalStateException: Conflicting/ambiguous property name definitions (implicit name 'myElements'): found multiple explicit names: [myElements, my_elements], but also implicit accessor: [field .....#myElements][visible=false,ignore=false,explicitName=false]
Do I need to add something more with Jersey 2.17? - Pritam