Replies: 2 comments 12 replies
-
I will see if I can create a reproducer for this. Thank you for reporting this @t1 |
Beta Was this translation helpful? Give feedback.
11 replies
-
I'm not sure I follow this. I don't see a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working mostly on WildFly (actually all the way back to since JBoss 4.0.2; currently 31.0.1). I generally let my JAX-RS services directly return instances of my own domain type, e.g.
Product
. If one of my clients doesn't specify whichContent-Type
they are ready toAccept
, they get a500 Internal Server Error
. IIUC, this is because RestEasy determines that it should return anapplication/octet-stream
, but there is noMessageBodyWriter
that could produce that from my domain type (only forbyte[]
, etc.).I see many people work around this by annotating all of their resource methods with
@Produces(APPLICATION_JSON)
. But IIUC, this mechanism was originally intended for when you have multiple methods for the same path returning aString
(et.al.). The@Produces
annotation can then be used to pick the method matching best to theAccept
header sent by the client. This is not only extra work, it also would prevent using a newMessageBodyWriter
for a newContent-Type
, e.g.application/yaml
.For a long time, I had assumed this to be the result of the spec defining
application/octet-stream
to be the fallback. But I just found out in an JAX-RS issue, that the specified algorithm is not implemented correctly in RestEasy: AsJsonBindingProvider
(andResteasyJackson2Provider
, andJAXBXmlRootElementProvider
, and probably some more) can produce a JSON (et.al.) from myProduct
. So the set of potential producersP
found in step 2 should contain them all. The set of acceptable content typesA
determined in step 4 has to be*/*
. Then step 8 should match and one of those types (preferablyapplication/json
) should be picked; step 9 should never be reached.I assume that the corresponding issue exists on the
@Consumes
side.I would very much appreciate it if this could be fixed and make my life easier. Thanks!
P.S.: I still wonder why this is not part of the TCK.
Beta Was this translation helpful? Give feedback.
All reactions