No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Franos13
Hello,

We have a rest Api which uses POJO classes with Bean Validation annotations (like @Pattern, @NotNull) and Jackson annotations like @JsonProperty.
Previously, using TomEE 7.0.2, we have no issue using the @JsonProperty Jackson annotation. Indeed, this kind of annotations was taken into account.

But when we migrate to 7.0.3, it seems that the @JsonProperty Jackson annotation is not anymore taking into account ☹
Is there any way to fix that ?

Best Regards.
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
Reply | Threaded
Open this post in threaded view
|

Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Romain Manni-Bucau
Hi

did you ensure jackson was set with application/json mediatype and not its
default */* which means "least prioritized" since JAXRS 2.0?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello,
>
> We have a rest Api which uses POJO classes with Bean Validation
> annotations (like @Pattern, @NotNull) and Jackson annotations like
> @JsonProperty.
> Previously, using TomEE 7.0.2, we have no issue using the @JsonProperty
> Jackson annotation. Indeed, this kind of annotations was taken into account.
>
> But when we migrate to 7.0.3, it seems that the @JsonProperty Jackson
> annotation is not anymore taking into account ☹
> Is there any way to fix that ?
>
> Best Regards.
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>
Reply | Threaded
Open this post in threaded view
|

RE: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Franos13
Hello Romain,

Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE 7.0.3, right ?
What do you mean by "ensure jackson was set with application/json mediatype" ?

We just use, as mentioned, Jackson annotations, we don't perform any initialization at Jackson level in our code ?

Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: jeudi 30 mars 2017 11:56
To: [hidden email]
Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Hi

did you ensure jackson was set with application/json mediatype and not its default */* which means "least prioritized" since JAXRS 2.0?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com>

2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello,
>
> We have a rest Api which uses POJO classes with Bean Validation
> annotations (like @Pattern, @NotNull) and Jackson annotations like
> @JsonProperty.
> Previously, using TomEE 7.0.2, we have no issue using the
> @JsonProperty Jackson annotation. Indeed, this kind of annotations was taken into account.
>
> But when we migrate to 7.0.3, it seems that the @JsonProperty Jackson
> annotation is not anymore taking into account ☹ Is there any way to
> fix that ?
>
> Best Regards.
> ________________________________
>  This message and any attachments are intended solely for the
> addressees and may contain confidential information. Any unauthorized
> use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable
> for the message if altered, changed or falsified. If you are not the
> intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this
> transmission free from viruses, the sender will not be liable for
> damages caused by a transmitted virus.
>
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
Reply | Threaded
Open this post in threaded view
|

Re: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Romain Manni-Bucau
2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello Romain,
>
> Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE 7.0.3,
> right ?
>

Yes


> What do you mean by "ensure jackson was set with application/json
> mediatype" ?
>

By default TomEE uses Johnzon since first 7.0.0 release. It sets it as the
least prioritized application/json provider to let the users use something
else and the usage be quite smooth and automatic.

Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2
resolution got clarified...and broke even if it shouldnt have been). In 2
words jackson uses */* which means the last one to use if none are
matching. Since johnzon uses application/json (and application/*+json IIRC)
then it is used cause matching the request where jackson doesnt.

If you wrap jackson provider in a custom one changing this @Consumes and
@Produces it will work automatically.

Here is the bug
https://github.com/FasterXML/jackson-jaxrs-json-provider/blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java#L55
for memories


>
> We just use, as mentioned, Jackson annotations, we don't perform any
> initialization at Jackson level in our code ?
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 11:56
> To: [hidden email]
> Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using
> @JsonProperty coming from jackson
>
> Hi
>
> did you ensure jackson was set with application/json mediatype and not its
> default */* which means "least prioritized" since JAXRS 2.0?
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> https://blog-rmannibucau.rhcloud.com> | Old Blog <
> http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau>
> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <
> https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello,
> >
> > We have a rest Api which uses POJO classes with Bean Validation
> > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > @JsonProperty.
> > Previously, using TomEE 7.0.2, we have no issue using the
> > @JsonProperty Jackson annotation. Indeed, this kind of annotations was
> taken into account.
> >
> > But when we migrate to 7.0.3, it seems that the @JsonProperty Jackson
> > annotation is not anymore taking into account ☹ Is there any way to
> > fix that ?
> >
> > Best Regards.
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any unauthorized
> > use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be liable
> > for the message if altered, changed or falsified. If you are not the
> > intended recipient of this message, please delete it and notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>
Reply | Threaded
Open this post in threaded view
|

RE: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Franos13
In reply to this post by Franos13
Hello Romain,

All our JAX-RS endpoints are annotated by with @Consumes({ MediaType.APPLICATION_JSON }) and /or  @Produces({ MediaType.APPLICATION_JSON }).
And no specific configuration has been done in order to set Jackson as the JAX-RS provider for our application.

So, does it mean that we have to explicitly define the JAX-RS provider in TomEE ?
If yes, the right way to do that is to have an openejb-jar.xml in the war with the following content ?
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
    <pojo-deployment  class-name="jaxrs-application">
        <properties>
            cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
        </properties>
    </pojo-deployment>
</openejb-jar>


Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: jeudi 30 mars 2017 12:47
To: [hidden email]
Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello Romain,
>
> Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> 7.0.3, right ?
>

Yes


> What do you mean by "ensure jackson was set with application/json
> mediatype" ?
>

By default TomEE uses Johnzon since first 7.0.0 release. It sets it as the least prioritized application/json provider to let the users use something else and the usage be quite smooth and automatic.

Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2 resolution got clarified...and broke even if it shouldnt have been). In 2 words jackson uses */* which means the last one to use if none are matching. Since johnzon uses application/json (and application/*+json IIRC) then it is used cause matching the request where jackson doesnt.

If you wrap jackson provider in a custom one changing this @Consumes and @Produces it will work automatically.

Here is the bug
https://github.com/FasterXML/jackson-jaxrs-json-provider/blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java#L55
for memories


>
> We just use, as mentioned, Jackson annotations, we don't perform any
> initialization at Jackson level in our code ?
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 11:56
> To: [hidden email]
> Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using
> @JsonProperty coming from jackson
>
> Hi
>
> did you ensure jackson was set with application/json mediatype and not
> its default */* which means "least prioritized" since JAXRS 2.0?
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> https://blog-rmannibucau.rhcloud.com> | Old Blog <
> http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau>
> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> | <
> https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello,
> >
> > We have a rest Api which uses POJO classes with Bean Validation
> > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > @JsonProperty.
> > Previously, using TomEE 7.0.2, we have no issue using the
> > @JsonProperty Jackson annotation. Indeed, this kind of annotations
> > was
> taken into account.
> >
> > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > Jackson annotation is not anymore taking into account ☹ Is there any
> > way to fix that ?
> >
> > Best Regards.
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any
> > unauthorized use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be
> > liable for the message if altered, changed or falsified. If you are
> > not the intended recipient of this message, please delete it and
> > notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the
> addressees and may contain confidential information. Any unauthorized
> use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable
> for the message if altered, changed or falsified. If you are not the
> intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this
> transmission free from viruses, the sender will not be liable for
> damages caused by a transmitted virus.
>
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
Reply | Threaded
Open this post in threaded view
|

Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Romain Manni-Bucau
2017-03-30 15:08 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello Romain,
>
> All our JAX-RS endpoints are annotated by with @Consumes({
> MediaType.APPLICATION_JSON }) and /or  @Produces({
> MediaType.APPLICATION_JSON }).
> And no specific configuration has been done in order to set Jackson as the
> JAX-RS provider for our application.
>

Was @Consumers/@Produces on the @Provider (jackson), not your endpoint.


>
> So, does it mean that we have to explicitly define the JAX-RS provider in
> TomEE ?
>

No, scanning still works as requested by users so you can do something like
(pseudo code, didnt check it compiles):

@Provider
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class JsonProv<T> implements MessageBodyReader<T>,
MessageBodyWriter<T> {
 private final JacksonJsonProvider delegate = new JacksonJsonProvider();

 // delegate all methods
}

And that's it


> If yes, the right way to do that is to have an openejb-jar.xml in the war
> with the following content ?
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
>     <pojo-deployment  class-name="jaxrs-application">
>         <properties>
>             cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.
> json.JacksonJsonProvider
>         </properties>
>     </pojo-deployment>
> </openejb-jar>
>
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 12:47
> To: [hidden email]
> Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue with
> 7.0.3 using @JsonProperty coming from jackson
>
> 2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello Romain,
> >
> > Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> > 7.0.3, right ?
> >
>
> Yes
>
>
> > What do you mean by "ensure jackson was set with application/json
> > mediatype" ?
> >
>
> By default TomEE uses Johnzon since first 7.0.0 release. It sets it as the
> least prioritized application/json provider to let the users use something
> else and the usage be quite smooth and automatic.
>
> Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2
> resolution got clarified...and broke even if it shouldnt have been). In 2
> words jackson uses */* which means the last one to use if none are
> matching. Since johnzon uses application/json (and application/*+json IIRC)
> then it is used cause matching the request where jackson doesnt.
>
> If you wrap jackson provider in a custom one changing this @Consumes and
> @Produces it will work automatically.
>
> Here is the bug
> https://github.com/FasterXML/jackson-jaxrs-json-provider/
> blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/
> JacksonJsonProvider.java#L55
> for memories
>
>
> >
> > We just use, as mentioned, Jackson annotations, we don't perform any
> > initialization at Jackson level in our code ?
> >
> > Best Regards.
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:[hidden email]]
> > Sent: jeudi 30 mars 2017 11:56
> > To: [hidden email]
> > Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using
> > @JsonProperty coming from jackson
> >
> > Hi
> >
> > did you ensure jackson was set with application/json mediatype and not
> > its default */* which means "least prioritized" since JAXRS 2.0?
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> > https://blog-rmannibucau.rhcloud.com> | Old Blog <
> > http://rmannibucau.wordpress.com> | Github
> > <https://github.com/rmannibucau>
> > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> > | <
> > https://javaeefactory-rmannibucau.rhcloud.com>
> >
> > 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> > [hidden email]>:
> >
> > > Hello,
> > >
> > > We have a rest Api which uses POJO classes with Bean Validation
> > > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > > @JsonProperty.
> > > Previously, using TomEE 7.0.2, we have no issue using the
> > > @JsonProperty Jackson annotation. Indeed, this kind of annotations
> > > was
> > taken into account.
> > >
> > > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > > Jackson annotation is not anymore taking into account ☹ Is there any
> > > way to fix that ?
> > >
> > > Best Regards.
> > > ________________________________
> > >  This message and any attachments are intended solely for the
> > > addressees and may contain confidential information. Any
> > > unauthorized use or disclosure, either whole or partial, is prohibited.
> > > E-mails are susceptible to alteration. Our company shall not be
> > > liable for the message if altered, changed or falsified. If you are
> > > not the intended recipient of this message, please delete it and
> > > notify the
> > sender.
> > > Although all reasonable efforts have been made to keep this
> > > transmission free from viruses, the sender will not be liable for
> > > damages caused by a transmitted virus.
> > >
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any unauthorized
> > use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be liable
> > for the message if altered, changed or falsified. If you are not the
> > intended recipient of this message, please delete it and notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>
Reply | Threaded
Open this post in threaded view
|

RE: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Franos13
In reply to this post by Franos13
Hello again,

For you information, I have now an openejb-jar.xml in my war under WEB-INF.
I have used cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider and cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider and have still the same issue :-(

Best Regards.

-----Original Message-----
From: COURTAULT Francois
Sent: jeudi 30 mars 2017 15:08
To: [hidden email]
Subject: RE: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Hello Romain,

All our JAX-RS endpoints are annotated by with @Consumes({ MediaType.APPLICATION_JSON }) and /or  @Produces({ MediaType.APPLICATION_JSON }).
And no specific configuration has been done in order to set Jackson as the JAX-RS provider for our application.

So, does it mean that we have to explicitly define the JAX-RS provider in TomEE ?
If yes, the right way to do that is to have an openejb-jar.xml in the war with the following content ?
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
    <pojo-deployment  class-name="jaxrs-application">
        <properties>
            cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
        </properties>
    </pojo-deployment>
</openejb-jar>


Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: jeudi 30 mars 2017 12:47
To: [hidden email]
Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello Romain,
>
> Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> 7.0.3, right ?
>

Yes


> What do you mean by "ensure jackson was set with application/json
> mediatype" ?
>

By default TomEE uses Johnzon since first 7.0.0 release. It sets it as the least prioritized application/json provider to let the users use something else and the usage be quite smooth and automatic.

Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2 resolution got clarified...and broke even if it shouldnt have been). In 2 words jackson uses */* which means the last one to use if none are matching. Since johnzon uses application/json (and application/*+json IIRC) then it is used cause matching the request where jackson doesnt.

If you wrap jackson provider in a custom one changing this @Consumes and @Produces it will work automatically.

Here is the bug
https://github.com/FasterXML/jackson-jaxrs-json-provider/blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java#L55
for memories


>
> We just use, as mentioned, Jackson annotations, we don't perform any
> initialization at Jackson level in our code ?
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 11:56
> To: [hidden email]
> Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using
> @JsonProperty coming from jackson
>
> Hi
>
> did you ensure jackson was set with application/json mediatype and not
> its default */* which means "least prioritized" since JAXRS 2.0?
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> https://blog-rmannibucau.rhcloud.com> | Old Blog <
> http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau>
> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> | <
> https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello,
> >
> > We have a rest Api which uses POJO classes with Bean Validation
> > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > @JsonProperty.
> > Previously, using TomEE 7.0.2, we have no issue using the
> > @JsonProperty Jackson annotation. Indeed, this kind of annotations
> > was
> taken into account.
> >
> > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > Jackson annotation is not anymore taking into account ☹ Is there any
> > way to fix that ?
> >
> > Best Regards.
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any
> > unauthorized use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be
> > liable for the message if altered, changed or falsified. If you are
> > not the intended recipient of this message, please delete it and
> > notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the
> addressees and may contain confidential information. Any unauthorized
> use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable
> for the message if altered, changed or falsified. If you are not the
> intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this
> transmission free from viruses, the sender will not be liable for
> damages caused by a transmitted virus.
>
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
Reply | Threaded
Open this post in threaded view
|

Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Romain Manni-Bucau
2017-03-30 15:44 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello again,
>
> For you information, I have now an openejb-jar.xml in my war under WEB-INF.
> I have used cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
> and cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
> and have still the same issue :-(
>
>
Sure, that's what I tried to explain. johnzon is added to ensure there is
always a provider - even on client side - and it is set as the least
prioritied of application/[*+]json providers to let you override it with
the json provider of your choice. Jackson not being a json provider you
need to get scanned or configure a json provider in tomee.


> Best Regards.
>
> -----Original Message-----
> From: COURTAULT Francois
> Sent: jeudi 30 mars 2017 15:08
> To: [hidden email]
> Subject: RE: Re: No issue with 7.0.2 but issue with 7.0.3 using
> @JsonProperty coming from jackson
>
> Hello Romain,
>
> All our JAX-RS endpoints are annotated by with @Consumes({
> MediaType.APPLICATION_JSON }) and /or  @Produces({
> MediaType.APPLICATION_JSON }).
> And no specific configuration has been done in order to set Jackson as the
> JAX-RS provider for our application.
>
> So, does it mean that we have to explicitly define the JAX-RS provider in
> TomEE ?
> If yes, the right way to do that is to have an openejb-jar.xml in the war
> with the following content ?
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
>     <pojo-deployment  class-name="jaxrs-application">
>         <properties>
>             cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.
> json.JacksonJsonProvider
>         </properties>
>     </pojo-deployment>
> </openejb-jar>
>
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 12:47
> To: [hidden email]
> Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue with
> 7.0.3 using @JsonProperty coming from jackson
>
> 2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello Romain,
> >
> > Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> > 7.0.3, right ?
> >
>
> Yes
>
>
> > What do you mean by "ensure jackson was set with application/json
> > mediatype" ?
> >
>
> By default TomEE uses Johnzon since first 7.0.0 release. It sets it as the
> least prioritized application/json provider to let the users use something
> else and the usage be quite smooth and automatic.
>
> Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2
> resolution got clarified...and broke even if it shouldnt have been). In 2
> words jackson uses */* which means the last one to use if none are
> matching. Since johnzon uses application/json (and application/*+json IIRC)
> then it is used cause matching the request where jackson doesnt.
>
> If you wrap jackson provider in a custom one changing this @Consumes and
> @Produces it will work automatically.
>
> Here is the bug
> https://github.com/FasterXML/jackson-jaxrs-json-provider/
> blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/
> JacksonJsonProvider.java#L55
> for memories
>
>
> >
> > We just use, as mentioned, Jackson annotations, we don't perform any
> > initialization at Jackson level in our code ?
> >
> > Best Regards.
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:[hidden email]]
> > Sent: jeudi 30 mars 2017 11:56
> > To: [hidden email]
> > Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3 using
> > @JsonProperty coming from jackson
> >
> > Hi
> >
> > did you ensure jackson was set with application/json mediatype and not
> > its default */* which means "least prioritized" since JAXRS 2.0?
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> > https://blog-rmannibucau.rhcloud.com> | Old Blog <
> > http://rmannibucau.wordpress.com> | Github
> > <https://github.com/rmannibucau>
> > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> > | <
> > https://javaeefactory-rmannibucau.rhcloud.com>
> >
> > 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> > [hidden email]>:
> >
> > > Hello,
> > >
> > > We have a rest Api which uses POJO classes with Bean Validation
> > > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > > @JsonProperty.
> > > Previously, using TomEE 7.0.2, we have no issue using the
> > > @JsonProperty Jackson annotation. Indeed, this kind of annotations
> > > was
> > taken into account.
> > >
> > > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > > Jackson annotation is not anymore taking into account ☹ Is there any
> > > way to fix that ?
> > >
> > > Best Regards.
> > > ________________________________
> > >  This message and any attachments are intended solely for the
> > > addressees and may contain confidential information. Any
> > > unauthorized use or disclosure, either whole or partial, is prohibited.
> > > E-mails are susceptible to alteration. Our company shall not be
> > > liable for the message if altered, changed or falsified. If you are
> > > not the intended recipient of this message, please delete it and
> > > notify the
> > sender.
> > > Although all reasonable efforts have been made to keep this
> > > transmission free from viruses, the sender will not be liable for
> > > damages caused by a transmitted virus.
> > >
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any unauthorized
> > use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be liable
> > for the message if altered, changed or falsified. If you are not the
> > intended recipient of this message, please delete it and notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>
Reply | Threaded
Open this post in threaded view
|

RE: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Franos13
In reply to this post by Romain Manni-Bucau
Hello,

The thing is that we have only @Provider defined for ExceptionMapper...

So, if I have understood you well, in order to use Jackson as the JAX-RS provider instead of Johnzon in TomEE 7.x,  I have to define a new provider class which delegates, in the methods we have to implement for the MessageBodyReader, MessageBodyWriter interfaces, to the JacksonJsonProvider, right ?

I will try to send you a test case in order to see what happens and why we have a different behavior between TomEE 7.0.2 and 7.0.3.

Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: jeudi 30 mars 2017 15:14
To: [hidden email]
Subject: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

2017-03-30 15:08 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello Romain,
>
> All our JAX-RS endpoints are annotated by with @Consumes({
> MediaType.APPLICATION_JSON }) and /or  @Produces({
> MediaType.APPLICATION_JSON }).
> And no specific configuration has been done in order to set Jackson as
> the JAX-RS provider for our application.
>

Was @Consumers/@Produces on the @Provider (jackson), not your endpoint.


>
> So, does it mean that we have to explicitly define the JAX-RS provider
> in TomEE ?
>

No, scanning still works as requested by users so you can do something like (pseudo code, didnt check it compiles):

@Provider
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class JsonProv<T> implements MessageBodyReader<T>, MessageBodyWriter<T> {  private final JacksonJsonProvider delegate = new JacksonJsonProvider();

 // delegate all methods
}

And that's it


> If yes, the right way to do that is to have an openejb-jar.xml in the
> war with the following content ?
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
>     <pojo-deployment  class-name="jaxrs-application">
>         <properties>
>             cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.
> json.JacksonJsonProvider
>         </properties>
>     </pojo-deployment>
> </openejb-jar>
>
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 12:47
> To: [hidden email]
> Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue
> with
> 7.0.3 using @JsonProperty coming from jackson
>
> 2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello Romain,
> >
> > Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> > 7.0.3, right ?
> >
>
> Yes
>
>
> > What do you mean by "ensure jackson was set with application/json
> > mediatype" ?
> >
>
> By default TomEE uses Johnzon since first 7.0.0 release. It sets it as
> the least prioritized application/json provider to let the users use
> something else and the usage be quite smooth and automatic.
>
> Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2
> resolution got clarified...and broke even if it shouldnt have been).
> In 2 words jackson uses */* which means the last one to use if none
> are matching. Since johnzon uses application/json (and
> application/*+json IIRC) then it is used cause matching the request where jackson doesnt.
>
> If you wrap jackson provider in a custom one changing this @Consumes
> and @Produces it will work automatically.
>
> Here is the bug
> https://github.com/FasterXML/jackson-jaxrs-json-provider/
> blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/
> JacksonJsonProvider.java#L55
> for memories
>
>
> >
> > We just use, as mentioned, Jackson annotations, we don't perform any
> > initialization at Jackson level in our code ?
> >
> > Best Regards.
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:[hidden email]]
> > Sent: jeudi 30 mars 2017 11:56
> > To: [hidden email]
> > Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3
> > using @JsonProperty coming from jackson
> >
> > Hi
> >
> > did you ensure jackson was set with application/json mediatype and
> > not its default */* which means "least prioritized" since JAXRS 2.0?
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> > https://blog-rmannibucau.rhcloud.com> | Old Blog <
> > http://rmannibucau.wordpress.com> | Github
> > <https://github.com/rmannibucau>
> > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE
> > | Factory <
> > https://javaeefactory-rmannibucau.rhcloud.com>
> >
> > 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> > [hidden email]>:
> >
> > > Hello,
> > >
> > > We have a rest Api which uses POJO classes with Bean Validation
> > > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > > @JsonProperty.
> > > Previously, using TomEE 7.0.2, we have no issue using the
> > > @JsonProperty Jackson annotation. Indeed, this kind of annotations
> > > was
> > taken into account.
> > >
> > > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > > Jackson annotation is not anymore taking into account ☹ Is there
> > > any way to fix that ?
> > >
> > > Best Regards.
> > > ________________________________
> > >  This message and any attachments are intended solely for the
> > > addressees and may contain confidential information. Any
> > > unauthorized use or disclosure, either whole or partial, is prohibited.
> > > E-mails are susceptible to alteration. Our company shall not be
> > > liable for the message if altered, changed or falsified. If you
> > > are not the intended recipient of this message, please delete it
> > > and notify the
> > sender.
> > > Although all reasonable efforts have been made to keep this
> > > transmission free from viruses, the sender will not be liable for
> > > damages caused by a transmitted virus.
> > >
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any
> > unauthorized use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be
> > liable for the message if altered, changed or falsified. If you are
> > not the intended recipient of this message, please delete it and
> > notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the
> addressees and may contain confidential information. Any unauthorized
> use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable
> for the message if altered, changed or falsified. If you are not the
> intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this
> transmission free from viruses, the sender will not be liable for
> damages caused by a transmitted virus.
>
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
Reply | Threaded
Open this post in threaded view
|

Re: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Romain Manni-Bucau
2017-03-30 18:41 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello,
>
> The thing is that we have only @Provider defined for ExceptionMapper...
>
> So, if I have understood you well, in order to use Jackson as the JAX-RS
> provider instead of Johnzon in TomEE 7.x,  I have to define a new provider
> class which delegates, in the methods we have to implement for the
> MessageBodyReader, MessageBodyWriter interfaces, to the
> JacksonJsonProvider, right ?
>
>
Yep, should be 5 methods only


> I will try to send you a test case in order to see what happens and why we
> have a different behavior between TomEE 7.0.2 and 7.0.3.
>

Think it is cause we migrated johnzon default to cxf bus instead of adding
it manually to apps and filter it out if johnzon is there. But to be honest
issue cause is still a bug in jackson (or a not backward compatible change
in jaxrs 2).




>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 15:14
> To: [hidden email]
> Subject: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using
> @JsonProperty coming from jackson
>
> 2017-03-30 15:08 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello Romain,
> >
> > All our JAX-RS endpoints are annotated by with @Consumes({
> > MediaType.APPLICATION_JSON }) and /or  @Produces({
> > MediaType.APPLICATION_JSON }).
> > And no specific configuration has been done in order to set Jackson as
> > the JAX-RS provider for our application.
> >
>
> Was @Consumers/@Produces on the @Provider (jackson), not your endpoint.
>
>
> >
> > So, does it mean that we have to explicitly define the JAX-RS provider
> > in TomEE ?
> >
>
> No, scanning still works as requested by users so you can do something
> like (pseudo code, didnt check it compiles):
>
> @Provider
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> public class JsonProv<T> implements MessageBodyReader<T>,
> MessageBodyWriter<T> {  private final JacksonJsonProvider delegate = new
> JacksonJsonProvider();
>
>  // delegate all methods
> }
>
> And that's it
>
>
> > If yes, the right way to do that is to have an openejb-jar.xml in the
> > war with the following content ?
> > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
> >     <pojo-deployment  class-name="jaxrs-application">
> >         <properties>
> >             cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.
> > json.JacksonJsonProvider
> >         </properties>
> >     </pojo-deployment>
> > </openejb-jar>
> >
> >
> > Best Regards.
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:[hidden email]]
> > Sent: jeudi 30 mars 2017 12:47
> > To: [hidden email]
> > Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue
> > with
> > 7.0.3 using @JsonProperty coming from jackson
> >
> > 2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
> > [hidden email]>:
> >
> > > Hello Romain,
> > >
> > > Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> > > 7.0.3, right ?
> > >
> >
> > Yes
> >
> >
> > > What do you mean by "ensure jackson was set with application/json
> > > mediatype" ?
> > >
> >
> > By default TomEE uses Johnzon since first 7.0.0 release. It sets it as
> > the least prioritized application/json provider to let the users use
> > something else and the usage be quite smooth and automatic.
> >
> > Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS 2
> > resolution got clarified...and broke even if it shouldnt have been).
> > In 2 words jackson uses */* which means the last one to use if none
> > are matching. Since johnzon uses application/json (and
> > application/*+json IIRC) then it is used cause matching the request
> where jackson doesnt.
> >
> > If you wrap jackson provider in a custom one changing this @Consumes
> > and @Produces it will work automatically.
> >
> > Here is the bug
> > https://github.com/FasterXML/jackson-jaxrs-json-provider/
> > blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/
> > JacksonJsonProvider.java#L55
> > for memories
> >
> >
> > >
> > > We just use, as mentioned, Jackson annotations, we don't perform any
> > > initialization at Jackson level in our code ?
> > >
> > > Best Regards.
> > >
> > > -----Original Message-----
> > > From: Romain Manni-Bucau [mailto:[hidden email]]
> > > Sent: jeudi 30 mars 2017 11:56
> > > To: [hidden email]
> > > Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3
> > > using @JsonProperty coming from jackson
> > >
> > > Hi
> > >
> > > did you ensure jackson was set with application/json mediatype and
> > > not its default */* which means "least prioritized" since JAXRS 2.0?
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> > > https://blog-rmannibucau.rhcloud.com> | Old Blog <
> > > http://rmannibucau.wordpress.com> | Github
> > > <https://github.com/rmannibucau>
> > > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE
> > > | Factory <
> > > https://javaeefactory-rmannibucau.rhcloud.com>
> > >
> > > 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> > > [hidden email]>:
> > >
> > > > Hello,
> > > >
> > > > We have a rest Api which uses POJO classes with Bean Validation
> > > > annotations (like @Pattern, @NotNull) and Jackson annotations like
> > > > @JsonProperty.
> > > > Previously, using TomEE 7.0.2, we have no issue using the
> > > > @JsonProperty Jackson annotation. Indeed, this kind of annotations
> > > > was
> > > taken into account.
> > > >
> > > > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > > > Jackson annotation is not anymore taking into account ☹ Is there
> > > > any way to fix that ?
> > > >
> > > > Best Regards.
> > > > ________________________________
> > > >  This message and any attachments are intended solely for the
> > > > addressees and may contain confidential information. Any
> > > > unauthorized use or disclosure, either whole or partial, is
> prohibited.
> > > > E-mails are susceptible to alteration. Our company shall not be
> > > > liable for the message if altered, changed or falsified. If you
> > > > are not the intended recipient of this message, please delete it
> > > > and notify the
> > > sender.
> > > > Although all reasonable efforts have been made to keep this
> > > > transmission free from viruses, the sender will not be liable for
> > > > damages caused by a transmitted virus.
> > > >
> > > ________________________________
> > >  This message and any attachments are intended solely for the
> > > addressees and may contain confidential information. Any
> > > unauthorized use or disclosure, either whole or partial, is prohibited.
> > > E-mails are susceptible to alteration. Our company shall not be
> > > liable for the message if altered, changed or falsified. If you are
> > > not the intended recipient of this message, please delete it and
> > > notify the
> > sender.
> > > Although all reasonable efforts have been made to keep this
> > > transmission free from viruses, the sender will not be liable for
> > > damages caused by a transmitted virus.
> > >
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any unauthorized
> > use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be liable
> > for the message if altered, changed or falsified. If you are not the
> > intended recipient of this message, please delete it and notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>
Reply | Threaded
Open this post in threaded view
|

RE: [+SPAM+]: Re: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Franos13
Hello Romain,

I tried your solution but I have one issue.
The signature readFrom  is public T readFrom(Class<T> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException

But JacksonJsonProvider has  the following signature public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException

So it doesn't compile with this code:
    @Override
    public T readFrom(Class<T> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
    return delegate.readFrom(aClass, type, annotations, mediaType, multivaluedMap, inputStream);
    }

Do you have a solution ?

Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: jeudi 30 mars 2017 18:44
To: [hidden email]
Subject: [+SPAM+]: Re: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

2017-03-30 18:41 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello,
>
> The thing is that we have only @Provider defined for ExceptionMapper...
>
> So, if I have understood you well, in order to use Jackson as the
> JAX-RS provider instead of Johnzon in TomEE 7.x,  I have to define a
> new provider class which delegates, in the methods we have to
> implement for the MessageBodyReader, MessageBodyWriter interfaces, to
> the JacksonJsonProvider, right ?
>
>
Yep, should be 5 methods only


> I will try to send you a test case in order to see what happens and
> why we have a different behavior between TomEE 7.0.2 and 7.0.3.
>

Think it is cause we migrated johnzon default to cxf bus instead of adding it manually to apps and filter it out if johnzon is there. But to be honest issue cause is still a bug in jackson (or a not backward compatible change in jaxrs 2).




>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 15:14
> To: [hidden email]
> Subject: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3
> using @JsonProperty coming from jackson
>
> 2017-03-30 15:08 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello Romain,
> >
> > All our JAX-RS endpoints are annotated by with @Consumes({
> > MediaType.APPLICATION_JSON }) and /or  @Produces({
> > MediaType.APPLICATION_JSON }).
> > And no specific configuration has been done in order to set Jackson
> > as the JAX-RS provider for our application.
> >
>
> Was @Consumers/@Produces on the @Provider (jackson), not your endpoint.
>
>
> >
> > So, does it mean that we have to explicitly define the JAX-RS
> > provider in TomEE ?
> >
>
> No, scanning still works as requested by users so you can do something
> like (pseudo code, didnt check it compiles):
>
> @Provider
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> public class JsonProv<T> implements MessageBodyReader<T>,
> MessageBodyWriter<T> {  private final JacksonJsonProvider delegate =
> new JacksonJsonProvider();
>
>  // delegate all methods
> }
>
> And that's it
>
>
> > If yes, the right way to do that is to have an openejb-jar.xml in
> > the war with the following content ?
> > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
> >     <pojo-deployment  class-name="jaxrs-application">
> >         <properties>
> >             cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.
> > json.JacksonJsonProvider
> >         </properties>
> >     </pojo-deployment>
> > </openejb-jar>
> >
> >
> > Best Regards.
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:[hidden email]]
> > Sent: jeudi 30 mars 2017 12:47
> > To: [hidden email]
> > Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue
> > with
> > 7.0.3 using @JsonProperty coming from jackson
> >
> > 2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
> > [hidden email]>:
> >
> > > Hello Romain,
> > >
> > > Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> > > 7.0.3, right ?
> > >
> >
> > Yes
> >
> >
> > > What do you mean by "ensure jackson was set with application/json
> > > mediatype" ?
> > >
> >
> > By default TomEE uses Johnzon since first 7.0.0 release. It sets it
> > as the least prioritized application/json provider to let the users
> > use something else and the usage be quite smooth and automatic.
> >
> > Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS
> > 2 resolution got clarified...and broke even if it shouldnt have been).
> > In 2 words jackson uses */* which means the last one to use if none
> > are matching. Since johnzon uses application/json (and
> > application/*+json IIRC) then it is used cause matching the request
> where jackson doesnt.
> >
> > If you wrap jackson provider in a custom one changing this @Consumes
> > and @Produces it will work automatically.
> >
> > Here is the bug
> > https://github.com/FasterXML/jackson-jaxrs-json-provider/
> > blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/
> > JacksonJsonProvider.java#L55
> > for memories
> >
> >
> > >
> > > We just use, as mentioned, Jackson annotations, we don't perform
> > > any initialization at Jackson level in our code ?
> > >
> > > Best Regards.
> > >
> > > -----Original Message-----
> > > From: Romain Manni-Bucau [mailto:[hidden email]]
> > > Sent: jeudi 30 mars 2017 11:56
> > > To: [hidden email]
> > > Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3
> > > using @JsonProperty coming from jackson
> > >
> > > Hi
> > >
> > > did you ensure jackson was set with application/json mediatype and
> > > not its default */* which means "least prioritized" since JAXRS 2.0?
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> > > https://blog-rmannibucau.rhcloud.com> | Old Blog <
> > > http://rmannibucau.wordpress.com> | Github
> > > <https://github.com/rmannibucau>
> > > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE
> > > | Factory <
> > > https://javaeefactory-rmannibucau.rhcloud.com>
> > >
> > > 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> > > [hidden email]>:
> > >
> > > > Hello,
> > > >
> > > > We have a rest Api which uses POJO classes with Bean Validation
> > > > annotations (like @Pattern, @NotNull) and Jackson annotations
> > > > like @JsonProperty.
> > > > Previously, using TomEE 7.0.2, we have no issue using the
> > > > @JsonProperty Jackson annotation. Indeed, this kind of
> > > > annotations was
> > > taken into account.
> > > >
> > > > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > > > Jackson annotation is not anymore taking into account ☹ Is there
> > > > any way to fix that ?
> > > >
> > > > Best Regards.
> > > > ________________________________  This message and any
> > > > attachments are intended solely for the addressees and may
> > > > contain confidential information. Any unauthorized use or
> > > > disclosure, either whole or partial, is
> prohibited.
> > > > E-mails are susceptible to alteration. Our company shall not be
> > > > liable for the message if altered, changed or falsified. If you
> > > > are not the intended recipient of this message, please delete it
> > > > and notify the
> > > sender.
> > > > Although all reasonable efforts have been made to keep this
> > > > transmission free from viruses, the sender will not be liable
> > > > for damages caused by a transmitted virus.
> > > >
> > > ________________________________
> > >  This message and any attachments are intended solely for the
> > > addressees and may contain confidential information. Any
> > > unauthorized use or disclosure, either whole or partial, is prohibited.
> > > E-mails are susceptible to alteration. Our company shall not be
> > > liable for the message if altered, changed or falsified. If you
> > > are not the intended recipient of this message, please delete it
> > > and notify the
> > sender.
> > > Although all reasonable efforts have been made to keep this
> > > transmission free from viruses, the sender will not be liable for
> > > damages caused by a transmitted virus.
> > >
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any
> > unauthorized use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be
> > liable for the message if altered, changed or falsified. If you are
> > not the intended recipient of this message, please delete it and
> > notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the
> addressees and may contain confidential information. Any unauthorized
> use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable
> for the message if altered, changed or falsified. If you are not the
> intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this
> transmission free from viruses, the sender will not be liable for
> damages caused by a transmitted virus.
>
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
Reply | Threaded
Open this post in threaded view
|

Re: [+SPAM+]: Re: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

Romain Manni-Bucau
set the generic=Object


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-03-30 18:55 GMT+02:00 COURTAULT Francois <
[hidden email]>:

> Hello Romain,
>
> I tried your solution but I have one issue.
> The signature readFrom  is public T readFrom(Class<T> aClass, Type type,
> Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,
> String> multivaluedMap, InputStream inputStream) throws IOException,
> WebApplicationException
>
> But JacksonJsonProvider has  the following signature public Object
> readFrom(Class<Object> type, Type genericType, Annotation[] annotations,
> MediaType mediaType, MultivaluedMap<String, String> httpHeaders,
> InputStream entityStream) throws IOException
>
> So it doesn't compile with this code:
>     @Override
>     public T readFrom(Class<T> aClass, Type type, Annotation[]
> annotations, MediaType mediaType, MultivaluedMap<String, String>
> multivaluedMap, InputStream inputStream) throws IOException,
> WebApplicationException {
>     return delegate.readFrom(aClass, type, annotations, mediaType,
> multivaluedMap, inputStream);
>     }
>
> Do you have a solution ?
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: jeudi 30 mars 2017 18:44
> To: [hidden email]
> Subject: [+SPAM+]: Re: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue
> with 7.0.3 using @JsonProperty coming from jackson
>
> 2017-03-30 18:41 GMT+02:00 COURTAULT Francois <
> [hidden email]>:
>
> > Hello,
> >
> > The thing is that we have only @Provider defined for ExceptionMapper...
> >
> > So, if I have understood you well, in order to use Jackson as the
> > JAX-RS provider instead of Johnzon in TomEE 7.x,  I have to define a
> > new provider class which delegates, in the methods we have to
> > implement for the MessageBodyReader, MessageBodyWriter interfaces, to
> > the JacksonJsonProvider, right ?
> >
> >
> Yep, should be 5 methods only
>
>
> > I will try to send you a test case in order to see what happens and
> > why we have a different behavior between TomEE 7.0.2 and 7.0.3.
> >
>
> Think it is cause we migrated johnzon default to cxf bus instead of adding
> it manually to apps and filter it out if johnzon is there. But to be honest
> issue cause is still a bug in jackson (or a not backward compatible change
> in jaxrs 2).
>
>
>
>
> >
> > Best Regards.
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:[hidden email]]
> > Sent: jeudi 30 mars 2017 15:14
> > To: [hidden email]
> > Subject: [+SPAM+]: Re: Re: No issue with 7.0.2 but issue with 7.0.3
> > using @JsonProperty coming from jackson
> >
> > 2017-03-30 15:08 GMT+02:00 COURTAULT Francois <
> > [hidden email]>:
> >
> > > Hello Romain,
> > >
> > > All our JAX-RS endpoints are annotated by with @Consumes({
> > > MediaType.APPLICATION_JSON }) and /or  @Produces({
> > > MediaType.APPLICATION_JSON }).
> > > And no specific configuration has been done in order to set Jackson
> > > as the JAX-RS provider for our application.
> > >
> >
> > Was @Consumers/@Produces on the @Provider (jackson), not your endpoint.
> >
> >
> > >
> > > So, does it mean that we have to explicitly define the JAX-RS
> > > provider in TomEE ?
> > >
> >
> > No, scanning still works as requested by users so you can do something
> > like (pseudo code, didnt check it compiles):
> >
> > @Provider
> > @Consumes(MediaType.APPLICATION_JSON)
> > @Produces(MediaType.APPLICATION_JSON)
> > public class JsonProv<T> implements MessageBodyReader<T>,
> > MessageBodyWriter<T> {  private final JacksonJsonProvider delegate =
> > new JacksonJsonProvider();
> >
> >  // delegate all methods
> > }
> >
> > And that's it
> >
> >
> > > If yes, the right way to do that is to have an openejb-jar.xml in
> > > the war with the following content ?
> > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
> > >     <pojo-deployment  class-name="jaxrs-application">
> > >         <properties>
> > >             cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.
> > > json.JacksonJsonProvider
> > >         </properties>
> > >     </pojo-deployment>
> > > </openejb-jar>
> > >
> > >
> > > Best Regards.
> > >
> > > -----Original Message-----
> > > From: Romain Manni-Bucau [mailto:[hidden email]]
> > > Sent: jeudi 30 mars 2017 12:47
> > > To: [hidden email]
> > > Subject: [+SPAM+]: Re: [+SPAM+]: Re: No issue with 7.0.2 but issue
> > > with
> > > 7.0.3 using @JsonProperty coming from jackson
> > >
> > > 2017-03-30 12:15 GMT+02:00 COURTAULT Francois <
> > > [hidden email]>:
> > >
> > > > Hello Romain,
> > > >
> > > > Not sure to understand. TomEE 7.0.2 is JAX-RS 2.0 as well as TomEE
> > > > 7.0.3, right ?
> > > >
> > >
> > > Yes
> > >
> > >
> > > > What do you mean by "ensure jackson was set with application/json
> > > > mediatype" ?
> > > >
> > >
> > > By default TomEE uses Johnzon since first 7.0.0 release. It sets it
> > > as the least prioritized application/json provider to let the users
> > > use something else and the usage be quite smooth and automatic.
> > >
> > > Jackson doesn't respect this JAXRS constraint (yes JAXRS 1 -> JAXRS
> > > 2 resolution got clarified...and broke even if it shouldnt have been).
> > > In 2 words jackson uses */* which means the last one to use if none
> > > are matching. Since johnzon uses application/json (and
> > > application/*+json IIRC) then it is used cause matching the request
> > where jackson doesnt.
> > >
> > > If you wrap jackson provider in a custom one changing this @Consumes
> > > and @Produces it will work automatically.
> > >
> > > Here is the bug
> > > https://github.com/FasterXML/jackson-jaxrs-json-provider/
> > > blob/master/src/main/java/com/fasterxml/jackson/jaxrs/json/
> > > JacksonJsonProvider.java#L55
> > > for memories
> > >
> > >
> > > >
> > > > We just use, as mentioned, Jackson annotations, we don't perform
> > > > any initialization at Jackson level in our code ?
> > > >
> > > > Best Regards.
> > > >
> > > > -----Original Message-----
> > > > From: Romain Manni-Bucau [mailto:[hidden email]]
> > > > Sent: jeudi 30 mars 2017 11:56
> > > > To: [hidden email]
> > > > Subject: [+SPAM+]: Re: No issue with 7.0.2 but issue with 7.0.3
> > > > using @JsonProperty coming from jackson
> > > >
> > > > Hi
> > > >
> > > > did you ensure jackson was set with application/json mediatype and
> > > > not its default */* which means "least prioritized" since JAXRS 2.0?
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog <
> > > > https://blog-rmannibucau.rhcloud.com> | Old Blog <
> > > > http://rmannibucau.wordpress.com> | Github
> > > > <https://github.com/rmannibucau>
> > > > | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE
> > > > | Factory <
> > > > https://javaeefactory-rmannibucau.rhcloud.com>
> > > >
> > > > 2017-03-30 11:54 GMT+02:00 COURTAULT Francois <
> > > > [hidden email]>:
> > > >
> > > > > Hello,
> > > > >
> > > > > We have a rest Api which uses POJO classes with Bean Validation
> > > > > annotations (like @Pattern, @NotNull) and Jackson annotations
> > > > > like @JsonProperty.
> > > > > Previously, using TomEE 7.0.2, we have no issue using the
> > > > > @JsonProperty Jackson annotation. Indeed, this kind of
> > > > > annotations was
> > > > taken into account.
> > > > >
> > > > > But when we migrate to 7.0.3, it seems that the @JsonProperty
> > > > > Jackson annotation is not anymore taking into account ☹ Is there
> > > > > any way to fix that ?
> > > > >
> > > > > Best Regards.
> > > > > ________________________________  This message and any
> > > > > attachments are intended solely for the addressees and may
> > > > > contain confidential information. Any unauthorized use or
> > > > > disclosure, either whole or partial, is
> > prohibited.
> > > > > E-mails are susceptible to alteration. Our company shall not be
> > > > > liable for the message if altered, changed or falsified. If you
> > > > > are not the intended recipient of this message, please delete it
> > > > > and notify the
> > > > sender.
> > > > > Although all reasonable efforts have been made to keep this
> > > > > transmission free from viruses, the sender will not be liable
> > > > > for damages caused by a transmitted virus.
> > > > >
> > > > ________________________________
> > > >  This message and any attachments are intended solely for the
> > > > addressees and may contain confidential information. Any
> > > > unauthorized use or disclosure, either whole or partial, is
> prohibited.
> > > > E-mails are susceptible to alteration. Our company shall not be
> > > > liable for the message if altered, changed or falsified. If you
> > > > are not the intended recipient of this message, please delete it
> > > > and notify the
> > > sender.
> > > > Although all reasonable efforts have been made to keep this
> > > > transmission free from viruses, the sender will not be liable for
> > > > damages caused by a transmitted virus.
> > > >
> > > ________________________________
> > >  This message and any attachments are intended solely for the
> > > addressees and may contain confidential information. Any
> > > unauthorized use or disclosure, either whole or partial, is prohibited.
> > > E-mails are susceptible to alteration. Our company shall not be
> > > liable for the message if altered, changed or falsified. If you are
> > > not the intended recipient of this message, please delete it and
> > > notify the
> > sender.
> > > Although all reasonable efforts have been made to keep this
> > > transmission free from viruses, the sender will not be liable for
> > > damages caused by a transmitted virus.
> > >
> > ________________________________
> >  This message and any attachments are intended solely for the
> > addressees and may contain confidential information. Any unauthorized
> > use or disclosure, either whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be liable
> > for the message if altered, changed or falsified. If you are not the
> > intended recipient of this message, please delete it and notify the
> sender.
> > Although all reasonable efforts have been made to keep this
> > transmission free from viruses, the sender will not be liable for
> > damages caused by a transmitted virus.
> >
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>
Reply | Threaded
Open this post in threaded view
|

Re: No issue with 7.0.2 but issue with 7.0.3 using @JsonProperty coming from jackson

jorbil
In reply to this post by Franos13
Hi, maybe you can change and use @JohnzonProperty() annotation instead. That worked for me, Regards /J