I can't capture ProcessingException when sending object instead of array
Every time you send an object instead of an expected array I get an javax.ws.rs.ProcessingException that cannot be captured by a ExceptionMapper<Exception> I have tried different jersey 2.0 versions with the same result.
Environment
Ubuntu or Windows / JDK 1.7 / Tomat 7
Affected Versions
[2.25]
Reported by Dissident
@pavelbucek said: Can you please share complete project? (ideally as github project, with described reproducer / curl command)
The exception here means that Jersey created incorrect mode somewhere - it tries to invoke resource method with different number of parameters. I haven't seen that before and the information on stackoveflow is not enough to reproduce the issue locally.
dissident said: http://www.jcgonzalez.com/img/TestJersey.zip This is a maven project.
http://localhost:8080/TestJersey/rest/hello/post Content-Type: application/json
I'm using RestClient for Firefox
Result OK [
{ "test":"123456" }
]
Result error
{ "test":"123456" }
@pavelbucek said: so you are expecting an array and you send just an element and you'll get this exception, is that correct?
Also, your GenericException, which implements ExceptionMapper, is not annotated with @Provider. @Path is only for resource classes.
Can you re-run the test and evaluate again?
dissident said: Now the issue seems to be that I can't capture a java.lang.IllegalArgumentException when I expect and array and I just send an element.
public Response testInJSON(@Valid Test[] test) {
dissident said: It seemed to work fine for a moment. The ProcessingException problem still persist.
schivmeister said: Any updates on this? I can confirm – I spent quite some time trying to debug this. It is not until I was composing a StackOverFlow post that I was led to the related question.
I am trying to produce a custom HTTP response for when the client submits an instance body but the endpoint expects a collection. In such cases the server (or Tomcat) produces 500 Internal Server Error, with a message pointing to "javax.ws.rs.ProcessingException: Resource Java method invocation error."
It looks like a child of ServletException, and the root cause is an IllegalArgumentException, but none of the three allowed me to filter for the exception in an ExceptionMapper. I then tried just Exception out of desperation, and to my shock, it did not catch the error either. My belief then was that the exception is produced before Jersey kicks in and handles the request and/or the exception mappers, and therefore the application is unable to map it.
Some pointers to workarounds would help, as I managed to catch the inverse of the problem (client submits collection body but server expects instance) with QueryException (it is outside of a WebApplicationException). So I am holding on to the belief that I can still map this one.
This issue was imported from java.net JIRA JERSEY-3222
Shortly before the 1-year-anniversary of this bug -- will there ever be progress on it?
Shortly after the 1 year anniversary --- +1.