[ 
https://issues.apache.org/jira/browse/TOMEE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16608158#comment-16608158
 ] 

Romain Manni-Bucau edited comment on TOMEE-2232 at 9/8/18 5:53 PM:
-------------------------------------------------------------------

The point is that it is nowhere is the spec that json must read jaxb 
annotations. Some vendors - oracle and jboss IIRC - did it before json become 
an api in javaee. Since it exists as an API (javaee 7) there is no ambiguity or 
overlap between jaxb and json.

If you want that not portable feature, configuring jackson as a provider is 
likely the fastest and sanest solution but since EE 7/8 it is saner to just use 
the javax.json API, in particular with the changes in java in java 9 and later.

Also, if you only want to handle the name and not the namespace stuff of jaxb 
you can implement a custom AccessMode in 30 LOC using johnzon and configure it 
in tomee. Saner than overriding tomee defaults and use an untested distro ;).


was (Author: romain.manni-bucau):
The point is that it is nowhere is the spec that json must read jaxb 
annotations. Some vendors - oracle and jboss IIRC - did it before json become 
an api in javaee. Since it exists as an API (javaee 7) there is no ambiguity or 
overlap between jaxb and json.

If you want that not portable feature, configuring jackson as a provider is 
likely the fastest and sanest solution but since EE 7/8 it is saner to just use 
the javax.json API, in particular with the changes in java in java 9 and later.

> TomEE doesn't honor @XMLElement() name when deserializing JSON
> --------------------------------------------------------------
>
>                 Key: TOMEE-2232
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2232
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 7.0.5
>            Reporter: Jonathan S Fisher
>            Priority: Critical
>
> We encountered a strange limitation while working with salesforce. We're 
> hitting their login OAUTH endpoint and it returns a JSON string like this:
> {code:json}
> {  
>    "access_token":"onebiglongstring",
>    "instance_url":"https://ab67.salesforce.com";,
>    "id":"https://test.salesforce.com/id/sfid/sifd";,
>    "token_type":"Bearer",
>    "issued_at":"1536415016572",
>    "signature":"morebase64"
> }
>  {code}
> So naturally we constructed the following Java class:
> {code:java}
> @Data
> public class SalesforceLoginToken {
>       @XmlElement(name = "access_token")
>       private String accessToken;
>       @XmlElement(name = "instance_url")
>       private String instanceUrl;
>       @XmlElement
>       private String id;
>       @XmlElement(name = "token_type")
>       private String tokenType;
>       @XmlElement(name = "issued_at")
>       private String issuedAt;
>       @XmlElement
>       private String signature;
> }
> {code}
> However, TomEE will not deserialize any of the fields where the name is 
> specified in the XMLElement. A [head-desking] workaround we're using is to 
> break javabean convention and write our variables like this:
> {code:java}
>       @XmlElement
>       private String token_type;
> {code}
> because this won't work. TomEE simply fills out null every time:
> {code:java}
>       @XmlElement(name = "token_type")
>       private String tokenType;
> {code}
> I believe this used to work in TomEE 1.7.5, I haven't tested on master or 
> anything else.
> Anyway thanks,
> -Jonathan



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to