Hi Jochen, As far as I understand, we *are* using JAX-RS. I'm only trying to write the status code directly because I don't know how else to set it. We've got an OpenAPI spec that promises to return a 202, and some auto-generated code that forces me to return a User object instead of a bare Response.
Cheers, A On Mon, Oct 19, 2020 at 3:51 PM Jochen Schalanda <[email protected]> wrote: > Hi Aditya, > > what's the reason you cannot use JAX-RS in your application and are trying > to write to HttpServletResponse directly? > > Maybe there's another way. > > Cheers, > Jochen > > Am 19.10.2020 um 19:29 schrieb Aditya Prasad <[email protected]>: > > Hi there, > > I have a resource file that looks like this: > > @Context > private HttpServletResponse httpServletResponse; > ... > public User getUser() { > // stuff > return user; > } > > I want to set status code 202. Unfortunately, calling > httpServletResponse.setStatusCode() doesn't work, because it gets > overridden. One suggestion I've heard is to call > httpServletResponse.getOutputStream().close(), but that prevents the > object from being written. Another suggestion I've heard is > httpServletResponse.getOutputStream().flushBuffer(), but in that case it > looks like the content type is being set wrong. My client reports: > > org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: > MessageBodyReader not found for media type=application/octet-stream, > type=foo.User, genericType=foo.User > > Is there any way to set the status and return an object without > serializing it myself? My code is auto-generated in such a way that I'm > forced to return User (and not Response). > > Thanks, > Aditya > > -- > You received this message because you are subscribed to the Google Groups > "dropwizard-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dropwizard-user/8d599355-5786-4024-b16b-54e8e7da70bbn%40googlegroups.com > <https://groups.google.com/d/msgid/dropwizard-user/8d599355-5786-4024-b16b-54e8e7da70bbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- > You received this message because you are subscribed to the Google Groups > "dropwizard-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dropwizard-user/168CC1DF-946A-4FF1-83B7-50B47E0D7EF4%40schalanda.name > <https://groups.google.com/d/msgid/dropwizard-user/168CC1DF-946A-4FF1-83B7-50B47E0D7EF4%40schalanda.name?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dropwizard-user/CAMx7i45o6Fi3M5GOQsGkMVb4LWtKWh%2Bt1Qsof7Ed7cpAobEKnQ%40mail.gmail.com.
