[
https://issues.apache.org/jira/browse/CXF-6082?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14196226#comment-14196226
]
Sergey Beryozkin commented on CXF-6082:
---------------------------------------
See: https://java.net/jira/browse/JAX_RS_SPEC-464
Jersey does not do it the portable way for sure...
Just do
Response.status(myStatus).entity(errorMessage).type("text/plain").build() and
it will do it
> method Response.StatusType.getReasonPhrase is never called by CXF to generate
> a response
> ----------------------------------------------------------------------------------------
>
> Key: CXF-6082
> URL: https://issues.apache.org/jira/browse/CXF-6082
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.0.2
> Reporter: Constantino Cronemberger
>
> I am trying to send a JAX-RS response passing in a custom status code message
> and I found that with CXF this is not possible.
> I checked the code and found that getReasonPhrase is never called and that
> neither HttpServletResponse.setStatus(int i, java.lang.String s) nor
> sendError(int i, java.lang.String s) are used in CXF.
> In fact I found a call to getReasonPhrase in the getStatusInfo of the
> ResposeImpl class, but at the end it is only used by the method
> WebApplicationException.computeExceptionMessage to create the message text of
> the exception, but it would be necessary to call setStatus or sendError
> anyway.
> Looks like this can be done with Jersey:
> http://www.codingpedia.org/ama/custom-reason-phrase-in-http-status-error-message-response-with-jax-rs-jersey
> but I have tested only with CXF.
> The workaround for my case should be simple: instead of generating the
> response with an ExceptionMapper I will create a regular servlet error page
> which will call sendError appropriately.
> I still don't have a clear idea of how I could implement this fix for CXF.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)