[jboss-jira] [JBoss JIRA] (WFLY-8209) JAX-RS Executes resource method even when input validation fails
R Searls (JIRA)
issues at jboss.org
Tue Apr 4 13:26:00 EDT 2017
[ https://issues.jboss.org/browse/WFLY-8209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13388756#comment-13388756 ]
R Searls commented on WFLY-8209:
--------------------------------
I have not been able to reproduce the behavior you have described.
I am running Fedora 24
mvn 3.3.9
JDK 1.8.0_72
I cloned https://github.com/jhovell/wildfly-swarm-examples/tree/jaxrs-validation
Built /home/rsearls/projects/wfly-8209/wildfly-swarm-examples/jaxrs/jaxrs-cdi/target/example-jaxrs-cdi.war
Could not find a way to run the test, JAXRSApplicationIT
Deployed example-jaxrs-cdi.war bld to wfly-10.0.0.Final and wfly10.1.0.Final,
and tested with curl
{code:java}
curl http://localhost:8080/example-jaxrs-cdi/employees
{code}
this passes
{code:java}
curl -H "Content-Type, application/json" -H "Accepts, application/json" -X POST -d '{"id":1,"name":null}' http://localhost:8080/example-jaxrs-cdi/employees
{code}
this fails on the server but with a different error msg
{code:java}
13:12:58,237 ERROR [stderr] (default task-1) [Employee(id=1, name=emp01), Employee(id=2, name=emp02)]
13:14:06,819 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-2) RESTEASY002010: Failed to execute: javax.ws.rs.NotSupportedException: RESTEASY003200: Could not find message body reader for type: class org.wildfly.swarm.examples.jaxrs.cdi.domain.model.Employee of content type: application/x-www-form-urlencoded
at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.throwReaderNotFound(ServerReaderInterceptorContext.java:52)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:75)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:52)
at org.jboss.resteasy.security.doseta.DigitalVerificationInterceptor.aroundReadFrom(DigitalVerificationInterceptor.java:34)
....
{code}
Can you provide more directions in how you ran this?
> JAX-RS Executes resource method even when input validation fails
> ----------------------------------------------------------------
>
> Key: WFLY-8209
> URL: https://issues.jboss.org/browse/WFLY-8209
> Project: WildFly
> Issue Type: Bug
> Components: REST
> Affects Versions: 10.1.0.Final
> Reporter: John Hovell
> Assignee: Alessio Soldano
>
> I have created an example which is actually a fork of the Wildfly Swarm repo. I could re-create the example:
> https://github.com/jhovell/wildfly-swarm-examples/tree/jaxrs-validation (project in subfolder jaxrs/jaxrs-cdi). The tip of this branch shows it is working in WF 10.0. The commit earlier shows it broken in WF 10.1.
> If a JAX-RS resource is defined as an interface with an implementation that doesn't have a single arg constructor, in WF 10.0 you had to work around the issue in a roundabout way by extending the Application class, using the BeanManager to get the actual bean (not the proxy) and register it with JAX-RS. This seemed to be the only solution as even if you made a bean with a @Produces method on a managed bean, Resteasy still wouldn't know how to construct the bean. You get a fairly generic error that Resteasy can't find a constructor for the implementation (not the interface). See error below.
> Despite being roundabout, this worked. In WF 10.1 the behavior is very surprising in that it executes the resource method even though input validation failed, and then it returns a 400 with a validation message (as expected) but with the nasty side effect that the resource method was executed (and it may have crashed due to null pointers, in which case the user gets 500 instead of 400).
> [pre]
> 2017-02-22 19:26:08,213 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 5) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: org.wildfly.swarm.examples.jaxrs.cdi.api.EmployeeController
> at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
> at org.jboss.threads.JBossThread.run(JBossThread.java:320)
> Caused by: java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: org.wildfly.swarm.examples.jaxrs.cdi.api.EmployeeController
> at org.jboss.resteasy.spi.metadata.ResourceBuilder.constructor(ResourceBuilder.java:692)
> at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.registered(POJOResourceFactory.java:42)
> at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:208)
> at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:194)
> at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:180)
> [pre]
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list