Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1296

Field constraints are not validated if resource is an EJB

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.0.15.Final
    • 3.0.14.Final
    • jaxrs
    • None

    Description

      Let there be a JAX-RS resource which is a stateless EJB and has a field-level Bean Validation constraint:

      @Path("/hikes")
      @Stateless
      public class HikeResource {
      
      	@NotNull
      	private String name;
      
      	public String getName() {
      		return name;
      	}
      
      	@POST
      	@Path("/createHike")
      	@Consumes("application/json")
      	@Produces({"application/json", "text/plain"})
      	public void createHike(@Min(1) long id, String from, String to) {
      		// nothing to do
      	}
      }
      

      The @Null constraint on the "name" field will not be validated upon invocation of the createHike() resource method. When removing the Stateless annotation, the constraint is validated as expected.

      This affects only classic bean validation constraints (fields, properties, class-level); The method parameter constraint @Min is validated in both cases.

      Attachments

        Issue Links

          Activity

            People

              rsigal@redhat.com Ronald Sigal
              gunnar.morling Gunnar Morling
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: