今天尝试将appfuse生成的demo在wtp下部署运行,当将项目文件部署并在wtp中导入项目后,便启动JBoss4.2运行效果,
但是deploy失败,出现一下关键错误栈信息
java 代码
- Error creating bean with name 'sessionFactory' defined in URL
- [jar:file:/D:/jboss-4.2.0.GA/server/default/deploy/appfusedemo.war/WEB-INF/lib/appfuse-hibernate-2.0-rc1.jar!/
- applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException:
- org.hibernate.validator.event.ValidateEventListener
也算就是这句
java 代码
- java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener
不过当时回忆使用
java 代码
命令的时候是可以正常运行且显示的,怀疑是web容器的问题,接着在Tomcat 6.0下部署运行,成功!
由于客户那边部署只能是用jboss,所以接着继续查原因,上网搜索(关键字"java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener "),发现csdn也有人提出这个问题,也是jboss,而且指出是使用了hibernate-annotations,不过该贴没有解决,因为appfuse 2.0也是使用hibernate-annotations的,所以我开始怀疑是程序lib包与服务器lib冲突,英文搜索结果中也有提出此问题者,后来在此贴处(http://forum.springframework.org/showthread.php?t=44433)找到以下提示
My solution
<!----><!---->
was delete hibernate-annotations.jar from the lib of jboss/default.
With this my application runs correctly in jboss4.0.3.
I suppose that in next versions of jboss this lib will be actualized.
I hope it helps someone with the same problem as me.
于是到
jboss-4.2.0.GA\server\default\lib,将hibernate-annotations.jar删除,重新部署启动jboss4.2搞定!
<!---->