0 Replies Latest reply on May 12, 2015 2:21 PM by Benjamin Hundley

    Validation of webservice parameters is inconsistent

    Benjamin Hundley Newbie

      I am dealing with a very weird issue.  I have dozens of web services deployed on JBoss EAP 6.3.  I am using resteasy and hibernate together to validate the parameters to these services.  The validation of the Query Params is inconsistent.  Sometimes the validation is completely ignored and sometimes it works.  Some of the web services have validation that works and some of them have validation that fails.  And which ones work and which ones fail is different every time I restart the server.  Anyone experienced anything like this before?  Anyone have any ideas as to what might cause this type of behavior?

       

       

      A typical web service looks like this:

       

      import java.sql.SQLException;

      import java.util.List;

       

      import javax.annotation.security.PermitAll;

      import javax.inject.Inject;

      import javax.validation.Valid;

      import javax.validation.constraints.NotNull;

      import javax.validation.constraints.Pattern;

      import javax.ws.rs.DefaultValue;

      import javax.ws.rs.GET;

      import javax.ws.rs.Path;

      import javax.ws.rs.PathParam;

      import javax.ws.rs.Produces;

      import javax.ws.rs.QueryParam;

      import javax.ws.rs.core.GenericEntity;

      import javax.ws.rs.core.MediaType;

      import javax.ws.rs.core.Response;

       

      import org.jboss.resteasy.spi.validation.ValidateRequest;

       

      @Path("/mypath")

      public class MyEndPoint {

       

          @Inject

          private MyResource myResource;

       

          @GET

          @PermitAll

          @Path("/secondpath")

          @ValidateRequest

          @Produces(MediaType.APPLICATION_JSON)

          public Response getSomething(@QueryParam("langCode") @DefaultValue("en_US") @Pattern(regexp = "[a-z]{2}_[A-Z]{2}", message = "ERR.006") String mylangCode) {

                        List<MyObject> returnValue= myResource.getMyValue(langCode);

                        GenericEntity<List<MyValue>> result = new GenericEntity<List<MyValue>>(returnValue) {};

                        return Response.ok(result).build();

          }

      }

       

      Relevent pom.xml dependencies:

       

                <dependency>

                  <groupId>org.jboss.resteasy</groupId>

                  <artifactId>resteasy-hibernatevalidator-provider</artifactId>

                  <scope>provided</scope>

              </dependency>

       

                <dependency>

                  <groupId>org.jboss.resteasy</groupId>

                  <artifactId>resteasy-jaxrs</artifactId>

                  <scope>provided</scope>

              </dependency>