如何在 Tapestry 中设置 Hibernate 验证器?
您好,我正在尝试将 Tapestry 5.2 的快速启动框架复制到 Eclipse 中的 Dynamic Web 项目。在快速启动项目中,我可以生成 war 文件并在 Tomcat 中运行它,但是当我尝试将项目及其依赖项复制到新的动态 Web 项目时,它会抛出异常:
原因:java.lang.ClassNotFoundException: javax.validation.ValidatorFactory
我确实将 hibernate 验证器复制到 web-inf/lib 但 Tapestry 找不到它。 我该如何在 Tapestry 中设置它?
Hi I'm trying to copy the quick start skeleton of Tapestry 5.2 to Dynamic Web project in eclipse. In the quick start project I can generate the war file and run it in Tomcat but when I try to copy the project with the dependences to a new Dynamic Web project it throw a exception:
Caused by: java.lang.ClassNotFoundException:
javax.validation.ValidatorFactory
I did copy the hibernate validator to web-inf/lib but tapestry can't find it.
How would I set it in Tapestry?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为这与挂毯或休眠有任何关系。您缺少
javax.validation.ValidatorFactory
在你的类路径上。该类与 JEE6 一起打包,在您的情况下,该类很可能是由您的 Tomcat 版本提供的,而不是由您的 Eclipse Web 项目提供的。您需要告诉您的 Web 项目使用 JEE6 或自己手动将 jar 添加到项目类路径中。
I don't believe this has anything to do with tapestry or hibernate. You are missing
javax.validation.ValidatorFactory
on your classpath. This class is packaged with JEE6 which in your case is most likely provided by your Tomcat version but not by your Eclipse Web Project.You will need to tell your Web Project to use JEE6 or add the jar manually yourself to the projects classpath.
这是我发现的一种方法,希望对你有用。
(a) 我正在运行来自 Eclipse Indigo 的 Tapestry。
(b) 我获得了 Tapestry-bin-5.2.6.tar.gz 的副本
(c) 将上述发行版的 lib 文件夹中存在的所有文件存储在类路径引用的文件夹(例如 foo)中
(d) 然后获得来自网络上不同位置的以下文件并将它们存储在同一文件夹 (foo) 中
(1) javax.validation-1.0.0.GA.jar(来自 http://www.java2s.com/Code/Jar/j/Downloadjavaxvalidation100GAjar.htm)
(2)hibernate-validator-4.2.0.Final和hibernate-validator-annotation-processor-4.2.0.Final
(来自 http://sourceforge.net/projects/hibernate/files/hibernate-validator/ )
(e) 重新启动 Eclipse - 并且成功了!
Here is one way that I found out, hope that it works for you.
(a) i am running tapestry from eclipse indigo.
(b) i obtained a copy of tapestry-bin-5.2.6.tar.gz
(c) stored all the files present in the lib folder of the above distribution in a folder (say foo) referenced by classpath
(d) then obtained the following files from various locations on the web an stored them in the same folder (foo)
(1) javax.validation-1.0.0.GA.jar (from http://www.java2s.com/Code/Jar/j/Downloadjavaxvalidation100GAjar.htm)
(2) hibernate-validator-4.2.0.Final and hibernate-validator-annotation-processor-4.2.0.Final
(from http://sourceforge.net/projects/hibernate/files/hibernate-validator/)
(e) restarted eclipse - and it worked !