<div dir="ltr">After some more digging, I have found that this issue occurs if the the rest endpoint is also defined as an ejb managed bean. e.g.<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre style="color:rgb(0,0,0);font-family:&quot;DejaVu Sans Mono&quot;;font-size:11.3pt"><span style="color:rgb(128,128,0)">@Stateless<br></span><span style="color:rgb(128,128,0)">@Path</span>(<span style="color:rgb(0,128,0);font-weight:bold">&quot;/policyholder&quot;</span>)<br><span style="color:rgb(128,128,0)">@Produces</span>(MediaType.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">APPLICATION_JSON</span>)<br><span style="color:rgb(128,128,0)">@Consumes</span>(MediaType.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">APPLICATION_JSON</span>)<br><span style="color:rgb(0,0,128);font-weight:bold">public class </span>PolicyHolderEndpoint {</pre></blockquote><div>In this case the JaxrsInjectionTarget.inject() is only called on the first endpoint invocation, and not on subsequent calls. </div><div><br></div><div>In the application the pusdo PolicyHolderEndpoint class is also a managed bean that is injected into other services as a single entry point for managing policyHolders.</div><div><br></div><div>Is it reasonable to expect a rest endpoint can also be defined as an ejb managed bean?</div><div><br></div><div><span style="color:rgb(0,0,0);font-size:12.8px">I need to look into why weld isn&#39;t injecting the </span><font color="#000000"><span style="font-size:12.8px">JaxrsInjectionTarget, but</span></font><span style="color:rgb(0,0,0);font-size:12.8px"> </span>I think that my original question still stands in this use case.  If we are running in a CDI context, we already ascertain in <span style="color:rgb(0,0,0);font-size:12.8px">MethodInjectorImpl.invoke() whether there are validation exceptions by calling [1]. Can we fail at this point, rather than delegating the validation to the CDI manager and waiting for a callback? </span></div><div><br></div><div>Thanks</div><div><span style="color:rgb(0,0,0);font-size:12.8px"><br></span></div><div><span style="color:rgb(0,0,0);font-size:12.8px">[1] - </span><font color="#000000"><span style="font-size:12.8px"><a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/MethodInjectorImpl.java#L119">https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/MethodInjectorImpl.java#L119</a></span></font></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 27, 2017 at 8:21 AM, John O&#39;Hara <span dir="ltr">&lt;<a href="mailto:johara@redhat.com" target="_blank">johara@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Ron,<div><br></div><div>I re-read your email and double checked the call to GeneralValidatorImpl.<wbr>checkViolationsfromCDI().</div><div><br></div><div>I only see this being called once, on the first request.</div><div><br></div><div>I will dig some more to see why it is not being called on all requests</div><div><br></div><div>Thanks</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>John</div><div><br></div><div><br></div></font></span></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Fri, Oct 27, 2017 at 8:03 AM, John O&#39;Hara <span dir="ltr">&lt;<a href="mailto:johara@redhat.com" target="_blank">johara@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span id="m_-7538084200824039342m_7348204419328560668gmail-docs-internal-guid-6a371e78-5c9b-bfaf-8ff7-6739edd31b00"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;vertical-align:baseline;white-space:pre-wrap">Thank you for your responses. If I fill you in on a bit of background about what I have experienced, then it might help clarify the issue I see.  </span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">Background</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">I am running a JEE benchmark on EAP7.1 (using resteasy 3.0.24.Final). One of rest endpoints has a @Valid annotation on a method parameter for a complex object.  </span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:4pt"><span style="font-size:11pt;font-family:Arial;color:rgb(128,128,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">@POST</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:4pt"><span style="font-size:11pt;font-family:Arial;color:rgb(128,128,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">@Path</span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">(</span><span style="font-size:11pt;font-family:Arial;color:rgb(0,128,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">&quot;/foo&quot;</span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">)</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:4pt"><span style="font-size:11pt;font-family:Arial;color:rgb(128,128,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">@Consumes</span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">(MediaType.</span><span style="font-size:11pt;font-family:Arial;color:rgb(102,14,122);background-color:transparent;font-weight:700;font-style:italic;vertical-align:baseline;white-space:pre-wrap">APPLICATIO<wbr>N_JSON</span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">)</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;margin-left:4pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,128);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">public void </span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">addFoo(</span><span style="font-size:11pt;font-family:Arial;color:rgb(128,128,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">@Valid </span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Foo bar) </span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,128);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">throws </span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Exception {</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">The Foo class contains different validation annotations, such as @NotNull, @Size, @Pattern and a custom validation annotation. </span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">One test determines how WF/EAP handles invalid requests. </span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">When I invoke the endpoint above I see a non-deterministic response from the app server.  If I invoke the endpoint with an invalid json object I receive a HTTP 400 exception as expected, but if I invoke the endpoint with a valid object, and *then* invoke the endpoint </span><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">with an invalid object I receive a HTTP 500 error. </span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">This exception only occurs on some property validation annotations and not all (e.g. @NotNull works as expected)</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">The test is being run in the context of CDI, and the HTTP 500 error is coming from the ejb3 subsystem. The ejb3 subsystem is wrapping the ConstraintValidationException raised by hibernate-validator.</span></p><br><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">Observations</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">In the call stack I capture [1], and WF thread dump [2] I can see;</span></p><br><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">The test is run in the context of CDI. The HTTP 500 response code message is caused by the ejb3 subsystem wrapping a ConstraintValidationException raised by hibernate-validator</span></p></li></ol><br><ol style="margin-top:0pt;margin-bottom:0pt" start="2"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">The validator is not called in ResourceMethodInvoker.invokeOn<wbr>Target() [3] as isValidatable is false [4], a ResteasyViolationException is not thrown</span></p></li></ol><br><ol style="margin-top:0pt;margin-bottom:0pt" start="3"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">The request is validated again here [5], the validation exceptions are not acted upon in this method call and the reflected method (which happens to be the Foo class constructor) is called here [6]</span></p></li></ol><br><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">Questions</span></p><br><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Why is ResourceMethodInvoker.isValida<wbr>table false in WF/EAP?</span></p></li><li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">If isValidatable is false, and validation occurs again at MethodInjectorImpl.invoke() can we not check for validation errors and raise the correct exception there as well?</span></p></li></ol><br><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">I have a standalone test that I will clean up and push out. There are some aspects of the test that can not be published publicly, so I need to modify them first.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Thanks,</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">John</span></p><br><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">[1] - see failing_4.stack  </span></p><p style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">[2] - see WF_stackTrace.out</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">[3] - </span><a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ResourceMethodInvoker.java#L305" style="text-decoration-line:none" target="_blank"><span style="font-size:11pt;font-family:Arial;background-color:transparent;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/resteasy/Re<wbr>steasy/blob/master/resteasy-ja<wbr>xrs/src/main/java/org/jboss/re<wbr>steasy/core/ResourceMethodInvo<wbr>ker.java#L305</span></a></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">[4] - </span><a href="https://github.com/resteasy/Resteasy/blob/master/providers/resteasy-validator-provider-11/src/main/java/org/jboss/resteasy/plugins/validation/GeneralValidatorImpl.java#L223" style="text-decoration-line:none" target="_blank"><span style="font-size:11pt;font-family:Arial;background-color:transparent;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/resteasy/Re<wbr>steasy/blob/master/providers/<wbr>resteasy-validator-provider-<wbr>11/src/main/java/org/jboss/<wbr>resteasy/plugins/validation/Ge<wbr>neralValidatorImpl.java#L223</span></a></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">[5] - </span><a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/MethodInjectorImpl.java#L119" style="text-decoration-line:none" target="_blank"><span style="font-size:11pt;font-family:Arial;background-color:transparent;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/resteasy/Re<wbr>steasy/blob/master/resteasy-ja<wbr>xrs/src/main/java/org/jboss/re<wbr>steasy/core/MethodInjectorImpl<wbr>.java#L119</span></a></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">[6] - </span><span style="text-decoration-line:underline;font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/MethodInjectorImpl.java#L140" style="text-decoration-line:none" target="_blank">https://github.com/resteasy/Re<wbr>steasy/blob/master/resteasy-ja<wbr>xrs/src/main/java/org/jboss/re<wbr>steasy/core/MethodInjectorImpl<wbr>.java#L140</a></span></p><div><br></div></span><div class="gmail_extra"><div class="m_-7538084200824039342m_7348204419328560668gmail-m_3837250096923988484gmail-m_-5821345287519690629gmail_signature"><div dir="ltr"><div style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px"><br></div></div></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="">-- <br><div class="m_-7538084200824039342gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-weight:bold;margin:0px;padding:0px;font-size:14px;text-transform:uppercase"><span>JOHN</span> <span>O&#39;HARA</span></p><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px;margin:0px 0px 4px;text-transform:uppercase"><span>PRINCIPAL SOFTWARE ENGINEER</span><span style="color:rgb(170,170,170);margin:0px"></span></p><p style="font-family:overpass,sans-serif;margin:0px;font-size:10px;color:rgb(153,153,153)"><a href="https://www.redhat.com/" style="color:rgb(0,136,206);margin:0px" target="_blank">Red Hat<span></span></a></p><table border="0" style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"><tbody><tr><td width="100px"><a href="https://red.ht/sig" target="_blank"><img src="https://www.redhat.com/files/brand/email/sig-redhat.png" width="90" height="auto"></a></td><td style="font-size:10px"><div><a href="https://redhat.com/trusted" style="color:rgb(204,0,0);font-weight:bold" target="_blank">TRIED. TESTED. TRUSTED.</a></div></td></tr></tbody></table><div style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px"><div style="color:rgb(153,153,153)"><a href="https://twitter.com/redhatway" title="twitter" style="background:url(&quot;https://www.redhat.com/files/brand/email/sm-twitter.png&quot;) 0px 50%/16px no-repeat transparent;height:20px;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px" target="_blank">@redhatway</a>   <a href="https://instagram.com/redhatinc" title="instagram" style="background:url(&quot;https://www.redhat.com/files/brand/email/sm-instagram.png&quot;) 0px 50%/16px no-repeat transparent;height:20px;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px" target="_blank">@redhatinc</a>   <a href="https://snapchat.com/add/redhatsnaps" title="snapchat" style="background:url(&quot;https://www.redhat.com/files/brand/email/sm-snapchat.png&quot;) 0px 50%/15px no-repeat transparent;height:20px;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px" target="_blank">@<wbr>redhatsnaps</a></div></div></div></div></div>
</span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-weight:bold;margin:0px;padding:0px;font-size:14px;text-transform:uppercase"><span>JOHN</span> <span>O&#39;HARA</span></p><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px;margin:0px 0px 4px;text-transform:uppercase"><span>PRINCIPAL SOFTWARE ENGINEER</span><span style="color:rgb(170,170,170);margin:0px"></span></p><p style="font-family:overpass,sans-serif;margin:0px;font-size:10px;color:rgb(153,153,153)"><a href="https://www.redhat.com/" style="color:rgb(0,136,206);margin:0px" target="_blank">Red Hat<span></span></a></p><table border="0" style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"><tbody><tr><td width="100px"><a href="https://red.ht/sig" target="_blank"><img src="https://www.redhat.com/files/brand/email/sig-redhat.png" width="90" height="auto"></a></td><td style="font-size:10px"><div><a href="https://redhat.com/trusted" style="color:rgb(204,0,0);font-weight:bold" target="_blank">TRIED. TESTED. TRUSTED.</a></div></td></tr></tbody></table><div style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px"><div style="color:rgb(153,153,153)"><a href="https://twitter.com/redhatway" title="twitter" style="background:url(&quot;https://www.redhat.com/files/brand/email/sm-twitter.png&quot;) 0px 50%/16px no-repeat transparent;height:20px;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px" target="_blank">@redhatway</a>   <a href="https://instagram.com/redhatinc" title="instagram" style="background:url(&quot;https://www.redhat.com/files/brand/email/sm-instagram.png&quot;) 0px 50%/16px no-repeat transparent;height:20px;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px" target="_blank">@redhatinc</a>   <a href="https://snapchat.com/add/redhatsnaps" title="snapchat" style="background:url(&quot;https://www.redhat.com/files/brand/email/sm-snapchat.png&quot;) 0px 50%/15px no-repeat transparent;height:20px;color:rgb(119,119,119);display:inline-block;line-height:20px;padding-left:16px" target="_blank">@redhatsnaps</a></div></div></div></div></div>
</div>