javax.validation.ValidationException: Unable to find a default provider

后端 未结 1 727
猫巷女王i
猫巷女王i 2021-01-22 03:47

I added some validation (@NotNull) to managed beans and suddenly got this error. Any ideas what might cause it? The application runs in Apache Tomcat 7.

<         


        
1条回答
  •  被撕碎了的回忆
    2021-01-22 04:32

    It appears that there is no JSR 303 Bean Validation provider in the classpath of your application in the application server. If you are using Glassfish, it would be better if you can verify the presence of bean-validator.jar in the $GLASSFISH_INSTALL_ROOT/glassfish/modules directory; Glassfish 3.1 uses this JAR (which contains the Hibernate Validator implementation) to serve as the default JSR 303 Bean Validation provider. I suspect that you are using an older version of Glassfish, or another application server that does not contain a Bean Validation provider.

    If you must include a Bean Validation provider in the classpath, consider reading the Java API documentation for the ValidationProviderResolver interface, which states that:

    Bean Validation providers are identified by the presence of META-INF/services/javax.validation.spi.ValidationProvider files following the Service Provider pattern described here

    Each META-INF/services/javax.validation.spi.ValidationProvider file contains the list of ValidationProvider implementations each of them representing a provider.

    Therefore, if you do include a Bean Validation provider in your classpath manually, you must ensure the presence of the META-INF/services/javax.validation.spi.ValidationProvider file in the classpath, and also that it contains the name of the Bean Validation provider. The contents of one provided by Glassfish is listed below, and points to the Hibernate Bean Validator class:

    org.hibernate.validator.HibernateValidator
    

    0 讨论(0)
提交回复
热议问题