11 Replies Latest reply on Nov 22, 2017 8:17 AM by Ron Sigal

    WildFly 11 - JAX-RS + EJB + Validation

    Stanislav Grushevskiy Newbie

      @Stateless

      @Path("/test")

      public class TestService {

          @POST

          public void test(@Valid TestForm form) {

              ...

          }

      }

       

      If I run this code at WildFly 10 and send form with errors, I get response with code 400 and json formatted errors.

      If I run this code at WildFly 11 and send form with errors, sometimes I get response with code 400 and json formatted errors and sometimes 500 and plain text.

       

      I found that sometimes the instance of this class is treated as JAX-RS bean and ResteasyViolationException is fired up, sometimes as EJB and ConstraintViolationException.

      There is ResteasyViolationExceptionMapper, that converts ResteasyViolationException to 400 and json response and ConstraintViolationException to 500 and plain text.

      Is it ok, that for the same requests I get different responces?

       

      If I remove @Stateless I always get 400 and json response (ResteasyViolationException is fired up).

       

       

      To make it works for @Stateless and @Path I've created exception mapper:

       

      package com.test.web.rest.exceptionhandler;

       

      import java.util.Arrays;

       

      import javax.validation.ConstraintViolationException;

      import javax.validation.ValidationException;

      import javax.ws.rs.core.MediaType;

      import javax.ws.rs.core.Response;

      import javax.ws.rs.ext.Provider;

       

      import org.jboss.resteasy.api.validation.ResteasyViolationException;

      import org.jboss.resteasy.api.validation.ResteasyViolationExceptionMapper;

       

      @Provider

      public class ConstraintViolationExceptionHandler extends ResteasyViolationExceptionMapper {

       

          @Override

          public Response toResponse(ValidationException exception) {

              if (!(exception instanceof ConstraintViolationException)) {

                  return super.toResponse(exception);

              }

              ResteasyViolationException e = exception instanceof ResteasyViolationException ?

                      (ResteasyViolationException) exception :

                      new ResteasyViolationException(((ConstraintViolationException) exception).getConstraintViolations(),

                              Arrays.asList(MediaType.APPLICATION_JSON_TYPE));

              return super.toResponse(e);

          }

       

      }

       

      test.zip - a simple reproducible application

      mvn wildfly:deploy - Maven command for deploy to WildFly 11

      http://localhost:8080/test/test.html - test url

       

      1. Press "Test Get" button

      2. Press "Test Post" button - 500 response with plain text

      3. Press "Test Post" button - 400 response with json

      4. Press "Test Post" button - 400 response with json

       

      5. Press "Test Get" button

      6. Press "Test Post" button - 500 response with plain text

      7. Press "Test Post" button - 400 response with json

      ...

        • 1. Re: WildFly 11 - JAX-RS + EJB + Validation
          jaikiran pai Master

          I found that sometimes the instance of this class is treated as JAX-RS bean and ResteasyViolationException is fired up, sometimes as EJB and ConstraintViolationException.

          ....

          Is it ok, that for the same requests I get different responces?

          It doesn't look right that the request is being handled in different ways for the same resource URI. If you have a simple reproducible application, can you attach it to the thread. Furthermore, since it looks like you have actually made progress in narrowing this down, can you attach the stacktraces of your invocations, for both these scenarios? That might give some hints on why it's following a certain code path.

          • 2. Re: WildFly 11 - JAX-RS + EJB + Validation
            Stanislav Grushevskiy Newbie

            Stacktrace + request/response dump - 400 + json

             

            12:59:31,375 ERROR [org.jboss.as.ejb3.invocation] (default task-63) WFLYEJB0034: EJB Invocation failed on component DepositService for method public void com.vdateam.ps.web.rest.service.admin.DepositService.markAsReviewed(com.vdateam.ps.web.rest.form.DepositReviewForm,javax.ws.rs.container.AsyncResponse): javax.ejb.EJBException: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:188)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:332)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:240)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)

                at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)

                at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.security.IdentityOutflowInterceptor.processInvocation(IdentityOutflowInterceptor.java:73)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.security.RolesAllowedInterceptor.processInvocation(RolesAllowedInterceptor.java:63)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.security.SecurityDomainInterceptor.processInvocation(SecurityDomainInterceptor.java:44)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:438)

                at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:609)

                at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:57)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)

                at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)

                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)

                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:81)

                at com.vdateam.ps.web.rest.service.admin.DepositService$$$view28.markAsReviewed(Unknown Source)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:498)

                at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)

                at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)

                at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)

                at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:406)

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:213)

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

                at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)

                at com.vdateam.ps.web.CipherKeyFilter.doFilter(CipherKeyFilter.java:45)

                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

                at com.vdateam.ps.web.XSRFRestFilter.doFilter(XSRFRestFilter.java:40)

                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

                at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)

                at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

                at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

                at org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.lambda$handleRequest$1(ElytronRunAsHandler.java:68)

                at org.wildfly.security.auth.server.FlexibleIdentityAssociation.runAsFunctionEx(FlexibleIdentityAssociation.java:101)

                at org.wildfly.security.auth.server.Scoped.runAsFunctionEx(Scoped.java:150)

                at org.wildfly.security.auth.server.Scoped.runAs(Scoped.java:62)

                at org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.handleRequest(ElytronRunAsHandler.java:67)

                at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

                at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

                at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)

                at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

                at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

                at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)

                at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

                at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

                at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

                at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

                at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

                at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

                at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

                at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

                at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)

                at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

                at java.lang.Thread.run(Thread.java:748)

            Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance

                at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)

                at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)

                at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)

                at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:64)

                at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:61)

                at org.jboss.as.ejb3.pool.AbstractPool.create(AbstractPool.java:56)

                at org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:124)

                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:47)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)

                ... 101 more

            Caused by: javax.ejb.EJBException: [PARAMETER]

            [markAsReviewed.arg0.comment]

            [may not be empty]

            []

             

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:188)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:349)

                at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:74)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)

                at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)

                ... 110 more

            Caused by: [PARAMETER]

            [markAsReviewed.arg0.comment]

            [may not be empty]

            []

             

                at org.jboss.resteasy.plugins.validation.GeneralValidatorImpl.checkViolationsfromCDI(GeneralValidatorImpl.java:143)

                at org.jboss.resteasy.cdi.JaxrsInjectionTarget.validate(JaxrsInjectionTarget.java:118)

                at org.jboss.resteasy.cdi.JaxrsInjectionTarget.inject(JaxrsInjectionTarget.java:67)

                at org.jboss.as.weld.injection.WeldInjectionContext.inject(WeldInjectionContext.java:39)

                at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:51)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:107)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:107)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.weld.interceptors.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:105)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)

                ... 123 more

             

            12:59:31,378 INFO  [io.undertow.request.dump] (default task-63)

            ----------------------------REQUEST---------------------------

                           URI=/ps/rest/admin/deposits/review

            characterEncoding=null

                 contentLength=21

                   contentType=[application/json;charset=utf-8]

                        cookie=JSESSIONID=Q7KFYldgOaf_31SaVUluX4JOwGzAaFoxvzWb8085.localhost

                        cookie=XSRF-TOKEN=71427414-03c3-491f-bcbf-722049a55fe8

                        cookie=cv_c=bXFyup929v8VRVyHXVr0pUttWX0DWssFFIgtKNre9foIKaTd+nuSUNtldoJba92eJezWqRpVKtY=

                        cookie=lang=it

                        header=Accept=application/json

                        header=Accept-Language=en,it;q=0.7,en-US;q=0.3

                        header=Accept-Encoding=gzip, deflate, br

                        header=User-Agent=Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0

                        header=Connection=close

                        header=Authorization=Basic YWRtaW46dGVzdA==

                        header=X-Forwarded-Proto=https

                        header=X-XSRF-TOKEN=71427414-03c3-491f-bcbf-722049a55fe8

                        header=X-Forwarded-For=192.168.121.36

                        header=Content-Length=21

                        header=Content-Type=application/json;charset=utf-8

                        header=Cookie=lang=it; XSRF-TOKEN=71427414-03c3-491f-bcbf-722049a55fe8; JSESSIONID=Q7KFYldgOaf_31SaVUluX4JOwGzAaFoxvzWb8085.localhost; cv_c="bXFyup929v8VRVyHXVr0pUttWX0DWssFFIgtKNre9foIKaTd+nuSUNtldoJba92eJezWqRpVKtY="

                        header=Referer=https://paymentservice.com/admin.html

                        header=Host=paymentservice.com

                        locale=[en, it, en_US]

                        method=PUT

                      protocol=HTTP/1.0

                   queryString=

                    remoteAddr=192.168.121.36:0

                    remoteHost=192.168.121.36

                        scheme=https

                          host=paymentservice.com

                    serverPort=8080

            --------------------------RESPONSE--------------------------

                 contentLength=243

                   contentType=application/json

                        header=Expires=0

                        header=Cache-Control=no-cache, no-store, must-revalidate

                        header=X-Powered-By=Undertow/1

                        header=Server=WildFly/11

                        header=Pragma=no-cache

                        header=Date=Thu, 09 Nov 2017 05:59:31 GMT

                        header=Connection=close

                        header=validation-exception=true

                        header=Content-Type=application/json

                        header=Content-Length=243

                        status=400

            ==============================================================

            • 3. Re: WildFly 11 - JAX-RS + EJB + Validation
              Stanislav Grushevskiy Newbie

              Stacktrace + request/response dump - 500 + plain text

               

              12:59:22,423 ERROR [org.jboss.as.ejb3.invocation] (default task-65) WFLYEJB0034: EJB Invocation failed on component DepositService for method public void com.vdateam.ps.web.rest.service.admin.DepositService.markAsReviewed(com.vdateam.ps.web.rest.form.DepositReviewForm,javax.ws.rs.container.AsyncResponse): javax.ejb.EJBException: javax.validation.ConstraintViolationException: 1 constraint violation(s) occurred during method validation.

              Constructor or Method: public void com.vdateam.ps.web.rest.service.admin.DepositService.markAsReviewed(com.vdateam.ps.web.rest.form.DepositReviewForm,javax.ws.rs.container.AsyncResponse)

              Argument values: [com.vdateam.ps.web.rest.form.DepositReviewForm@28088f49, org.jboss.resteasy.plugins.server.servlet.Servlet3AsyncHttpRequest$Servlet3ExecutionContext$Servle3AsychronousResponse@eeab9a9]

              Constraint violations:

              (1) Kind: PROPERTY

              message: may not be empty

              root bean: com.vdateam.ps.web.rest.service.admin.DepositService@453204cf

              property path: markAsReviewed.arg0.comment

              constraint: @org.hibernate.validator.constraints.NotBlank(message={org.hibernate.validator.constraints.NotBlank.message}, payload=[], groups=[])

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:188)

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:332)

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:240)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)

                  at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)

                  at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.security.IdentityOutflowInterceptor.processInvocation(IdentityOutflowInterceptor.java:73)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.security.RolesAllowedInterceptor.processInvocation(RolesAllowedInterceptor.java:63)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.security.SecurityDomainInterceptor.processInvocation(SecurityDomainInterceptor.java:44)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:438)

                  at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:609)

                  at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:57)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)

                  at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)

                  at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)

                  at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:81)

                  at com.vdateam.ps.web.rest.service.admin.DepositService$$$view28.markAsReviewed(Unknown Source)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at java.lang.reflect.Method.invoke(Method.java:498)

                  at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)

                  at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)

                  at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)

                  at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)

                  at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:406)

                  at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:213)

                  at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)

                  at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)

                  at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)

                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

                  at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

                  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)

                  at com.vdateam.ps.web.CipherKeyFilter.doFilter(CipherKeyFilter.java:45)

                  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

                  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

                  at com.vdateam.ps.web.XSRFRestFilter.doFilter(XSRFRestFilter.java:40)

                  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

                  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

                  at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)

                  at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

                  at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

                  at org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.lambda$handleRequest$1(ElytronRunAsHandler.java:68)

                  at org.wildfly.security.auth.server.FlexibleIdentityAssociation.runAsFunctionEx(FlexibleIdentityAssociation.java:101)

                  at org.wildfly.security.auth.server.Scoped.runAsFunctionEx(Scoped.java:150)

                  at org.wildfly.security.auth.server.Scoped.runAs(Scoped.java:62)

                  at org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.handleRequest(ElytronRunAsHandler.java:67)

                  at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

                  at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

                  at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)

                  at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

                  at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

                  at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)

                  at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

                  at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

                  at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

                  at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

                  at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

                  at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

                  at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                  at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                  at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                  at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                  at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                  at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

                  at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

                  at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

                  at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)

                  at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)

                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

                  at java.lang.Thread.run(Thread.java:748)

              Caused by: javax.validation.ConstraintViolationException: 1 constraint violation(s) occurred during method validation.

              Constructor or Method: public void com.vdateam.ps.web.rest.service.admin.DepositService.markAsReviewed(com.vdateam.ps.web.rest.form.DepositReviewForm,javax.ws.rs.container.AsyncResponse)

              Argument values: [com.vdateam.ps.web.rest.form.DepositReviewForm@28088f49, org.jboss.resteasy.plugins.server.servlet.Servlet3AsyncHttpRequest$Servlet3ExecutionContext$Servle3AsychronousResponse@eeab9a9]

              Constraint violations:

              (1) Kind: PROPERTY

              message: may not be empty

              root bean: com.vdateam.ps.web.rest.service.admin.DepositService@453204cf

              property path: markAsReviewed.arg0.comment

              constraint: @org.hibernate.validator.constraints.NotBlank(message={org.hibernate.validator.constraints.NotBlank.message}, payload=[], groups=[])

                  at org.hibernate.validator.internal.cdi.interceptor.ValidationInterceptor.validateMethodInvocation(ValidationInterceptor.java:74)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at java.lang.reflect.Method.invoke(Method.java:498)

                  at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)

                  at org.jboss.weld.interceptor.proxy.WeldInvocationContext.invokeNext(WeldInvocationContext.java:83)

                  at org.jboss.weld.interceptor.proxy.WeldInvocationContext.proceed(WeldInvocationContext.java:115)

                  at org.jboss.weld.bean.InterceptorImpl.intercept(InterceptorImpl.java:108)

                  at org.jboss.as.weld.ejb.DelegatingInterceptorInvocationContext.proceed(DelegatingInterceptorInvocationContext.java:82)

                  at org.jboss.as.weld.interceptors.EjbComponentInterceptorSupport.delegateInterception(EjbComponentInterceptorSupport.java:60)

                  at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.delegateInterception(Jsr299BindingsInterceptor.java:76)

                  at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:88)

                  at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101)

                  at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)

                  at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)

                  ... 101 more

               

              12:59:22,425 INFO  [io.undertow.request.dump] (default task-65)

              ----------------------------REQUEST---------------------------

                             URI=/ps/rest/admin/deposits/review

              characterEncoding=null

                   contentLength=21

                     contentType=[application/json;charset=utf-8]

                          cookie=JSESSIONID=Q7KFYldgOaf_31SaVUluX4JOwGzAaFoxvzWb8085.localhost

                          cookie=XSRF-TOKEN=71427414-03c3-491f-bcbf-722049a55fe8

                          cookie=cv_c=bXFyup929v8VRVyHXVr0pUttWX0DWssFFIgtKNre9foIKaTd+nuSUNtldoJba92eJezWqRpVKtY=

                          cookie=lang=it

                          header=Accept=application/json

                          header=Accept-Language=en,it;q=0.7,en-US;q=0.3

                          header=Accept-Encoding=gzip, deflate, br

                          header=User-Agent=Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0

                          header=Connection=close

                          header=Authorization=Basic YWRtaW46dGVzdA==

                          header=X-Forwarded-Proto=https

                          header=X-XSRF-TOKEN=71427414-03c3-491f-bcbf-722049a55fe8

                          header=X-Forwarded-For=192.168.121.36

                          header=Content-Length=21

                          header=Content-Type=application/json;charset=utf-8

                          header=Cookie=lang=it; XSRF-TOKEN=71427414-03c3-491f-bcbf-722049a55fe8; JSESSIONID=Q7KFYldgOaf_31SaVUluX4JOwGzAaFoxvzWb8085.localhost; cv_c="bXFyup929v8VRVyHXVr0pUttWX0DWssFFIgtKNre9foIKaTd+nuSUNtldoJba92eJezWqRpVKtY="

                          header=Referer=https://paymentservice.com/admin.html

                          header=Host=paymentservice.com

                          locale=[en, it, en_US]

                          method=PUT

                        protocol=HTTP/1.0

                     queryString=

                      remoteAddr=192.168.121.36:0

                      remoteHost=192.168.121.36

                          scheme=https

                            host=paymentservice.com

                      serverPort=8080

              --------------------------RESPONSE--------------------------

                   contentLength=832

                     contentType=text/plain;charset=UTF-8

                          header=Expires=0

                          header=Cache-Control=no-cache, no-store, must-revalidate

                          header=X-Powered-By=Undertow/1

                          header=Server=WildFly/11

                          header=Pragma=no-cache

                          header=Date=Thu, 09 Nov 2017 05:59:22 GMT

                          header=Connection=close

                          header=validation-exception=true

                          header=Content-Type=text/plain;charset=UTF-8

                          header=Content-Length=832

                          status=500

              ==============================================================

              • 4. Re: WildFly 11 - JAX-RS + EJB + Validation
                Stanislav Grushevskiy Newbie

                test.zip - a simple reproducible application

                mvn wildfly:deploy - Maven command for deploy to WildFly 11

                http://localhost:8080/test/test.html - test url

                 

                1. Press "Test Get" button

                2. Press "Test Post" button - 500 response with plain text

                3. Press "Test Post" button - 400 response with json

                4. Press "Test Post" button - 400 response with json

                 

                5. Press "Test Get" button

                6. Press "Test Post" button - 500 response with plain text

                7. Press "Test Post" button - 400 response with json

                ...

                • 5. Re: WildFly 11 - JAX-RS + EJB + Validation
                  Ron Sigal Master

                  Hi Stanislav,

                   

                  Coincidentally, a similar (or identical) issue came to my attention recently: see [RESTEASY-1749] Method Parameters are only validated on first invocation of an ejb managed rest endpoint - JBoss Issue T… . I've been working on it, but haven't nailed it yet.

                   

                  Jaikiran ... Oooh, oooh, if anyone can help, it's you!!!  Under some conditions, described in RESTEASY-1749, EJB3 interjects itself and does parameter validation outside the control of Resteasy. In the presence of CDI, this turns out to be a problem. In particular, CDI doesn't inject fields into an object until a method is called on the object, so Resteasy does field validation AFTER parameter validation. When EJB3 throws an exception after doing parameter validation, Resteasy doesn't get a chance to do field validation. This violates the Validation spec.

                   

                  Jaikiran, I think the best thing would be to turn off EJB3 validation. Do you know how to do that?

                   

                  -Ron

                  • 6. Re: WildFly 11 - JAX-RS + EJB + Validation
                    John O'Hara Newbie

                    The stack traces look very similar to the stack traces seen by  https://issues.jboss.org/browse/RESTEASY-1749

                     

                    I ran the RESTEASY-1749 test against WF10, and the tests are failing against that version as well.

                     

                    I will take a look at this test case to see if it is the same issue

                     

                    -John

                    • 7. Re: WildFly 11 - JAX-RS + EJB + Validation
                      Ron Sigal Master

                      Thank you, John.

                      • 8. Re: WildFly 11 - JAX-RS + EJB + Validation
                        John O'Hara Newbie

                        I can confirm that this issue is the same as  https://issues.jboss.org/browse/RESTEASY-1749

                         

                        @Stanislav Grushevskiy can you please double check this test on WF10, as I am seeing if fail there as well (running on wildfly-10.1.0.Final)

                         

                        As this is RESTEASY-1749, I will be updating progress on this issue on that jira.

                         

                        Thanks

                         

                        --John

                        • 9. Re: WildFly 11 - JAX-RS + EJB + Validation
                          Stanislav Grushevskiy Newbie

                          My bad, I didn't mention that WildFly 10 is 10.0.0.Final - here test works. Yes, on 10.1.0.Final it fails.

                          • 10. Re: WildFly 11 - JAX-RS + EJB + Validation
                            jaikiran pai Master

                            Sorry Ron, just catching up on this thread today and couldn't respond earlier. Based on your comments in the linked JIRA I'm guessing you have found some way past this.

                            • 11. Re: WildFly 11 - JAX-RS + EJB + Validation
                              Ron Sigal Master

                              Hi Jaikiran,

                               

                              Nice to hear from you. Thanks!!

                               

                              I still have one test failure that I haven't had time to look into yet. If I could turn off validation by EJB, that would probably be preferable.

                               

                              I'm about to leave for holiday, so I might not see your response until next week.

                               

                              -Ron