1 Reply Latest reply on Jan 6, 2014 5:27 AM by Martin Kouba

    too many validator initialization?

    John Franey Novice

      I'm injecting a validator (weld, hibernate validator) in a jax-rs application (resteasy) within the jboss eap6.1 runtime.

       

      I assume that the validator is initialized once for the application.  By 'initialized' I mean, that it finds, parses and loads validaton.xml once.  Logs tell a different story.  Looks like the validator is initialized four times per request, by looking at its access to the configuration file 'validation.xml'.  I've come to the weld community after checking with the resteasy community confirm that my programming is not wrong for jax-rs.

       

       

      This is the log messages I see, per http request.  It looks like weld initiates 4 initializations:

       

      17:38:14,022 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml found. Parsing XML based configuration.

      17:38:14,027 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000003: Using org.jboss.seam.validation.InjectingConstraintValidatorFactory as constraint factory.

      17:38:14,046 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml found. Parsing XML based configuration.

      17:38:14,051 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000003: Using org.jboss.seam.validation.InjectingConstraintValidatorFactory as constraint factory.

      17:38:14,068 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml found. Parsing XML based configuration.

      17:38:14,073 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000003: Using org.jboss.seam.validation.InjectingConstraintValidatorFactory as constraint factory.

      17:38:14,093 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000007: META-INF/validation.xml found. Parsing XML based configuration.

      17:38:14,099 INFO  [org.hibernate.validator.internal.xml.ValidationXmlParser] (http-localhost/127.0.0.1:8080-1) HV000003: Using org.jboss.seam.validation.InjectingConstraintValidatorFactory as constraint factory.

       

       

       

      This is a simplification of my code:

       

      @Path(....)

      public class MyResource {

       

        @Inject

        private Validator validator;

       

        @PUT

        public create(MyObject myObject) {

             validator.validate(myObject);

             .....

        }

      }}