Not getting JSR303 annotations to work with Tomcat 7

后端 未结 2 354
南方客
南方客 2021-01-27 05:13

After a couple hours of Google and a couple of tutorials I\'m beat... It\'s not the fact that I\'m getting errors that can give me hints on what the problem is, it\'s the comple

相关标签:
2条回答
  • 2021-01-27 05:50

    I had the same kind of problem, and search for a while, in my case, using hibernate-validator-4.2.0.Final.jar, I was lacking slf4j-api-1.6.4.jar. The problem is that hibernate validator does not crash but does NOT tell it is not working ....

    0 讨论(0)
  • 2021-01-27 05:51

    As for the libs, I've inluded the "validation-api-1.0.0.GA.jar" both in the "WEB-INF/lib" folder and also the "apache-tomcat-7/lib" folder.

    You've installed only the API, not the implementation. The API is an abstract contract so that you can declare/use it in your code and have the freedom in choosing the implementation. The implementation contains the concrete code and does the real work. You need to install the impl as well. The JSR-303 reference implemtation is the Hibernate Validator. The download details are here. Currently the latest final is 4.1.0. It contains the hibernate-validator-4.1.0.Final.jar file which is the real implementation. Drop it in Webapp/WEB-INF/lib. It does not necessarily need to be in Tomcat7/lib, I'd remove the API from there as well to prevent future classpath collisions.

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