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

假装没事ソ 提交于 2019-12-02 01:45:13

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!