Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-12668

Bean validation is done twice in JAX-RS application

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 17.0.1.Final, 18.0.0.Final
    • Fix Version/s: None
    • Component/s: Bean Validation, EJB, REST
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      I created a basic examle at https://github.com/bender316/wildfly-validation-bug

      You can either download the wildfly-validation-bug.war or clone the repository and do "gradle war" and deploy the war in build/libs to the WildFly.

      Steps:
      1. Deploy war
      2. Do a valid POST request against http://localhost:9080/wildfly-validation-bug/rest/test with the body:
      {
      "value": "123"
      }
      3. Do an invalid POST request with four characters (e.g. "1234" in the value field.
      4. Check result. There should be two error messages with the same content.
      5. Do 3. and 4. again. There should now be only 1 error message.
      6. Repeat 2. to 5.

      Show
      I created a basic examle at https://github.com/bender316/wildfly-validation-bug You can either download the wildfly-validation-bug.war or clone the repository and do "gradle war" and deploy the war in build/libs to the WildFly. Steps: 1. Deploy war 2. Do a valid POST request against http://localhost:9080/wildfly-validation-bug/rest/test with the body: { "value": "123" } 3. Do an invalid POST request with four characters (e.g. "1234" in the value field. 4. Check result. There should be two error messages with the same content. 5. Do 3. and 4. again. There should now be only 1 error message. 6. Repeat 2. to 5.

      Description

      If a JAX-RS resource is implemented as a stateless session bean then the validation is done twice: first on the EJB proxy and on the real implementation. This results in two constraint errors although there is basically just one error.

      The interesting part: If you resend the request. Then you get a proper result with just one violation. If you do a valid request and then an invalid you get the two violations again (see also the reproduce section).

      I created the issue here because I think it is an integration issue with JAX-RS, bean validation and EJBs.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                cfang Cheng Fang
                Reporter:
                bender316 Daniel Munzinger
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: