JBoss and different versions of Hibernate

冷暖自知 提交于 2019-11-28 09:17:05

Maybe too late, but it may help somebody that finds this thread looking for the problem described above about 'Caused by: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator....':

I'm using Jboss 4.2, Hibernate Core 3.6.5, Hibernate Validator 4.1.0, using maven, and I have the same problem. Finally I've solved it adding also this dependency:

    <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-validator-legacy</artifactId>
          <version>4.0.2.GA</version>
    </dependency>

I didn't test this personally, but the following thread mentions two approaches that you could try (yeah, I know, it's about JBoss 5 but it looks like the problem is identical).

Option 1

Disable java2ParentDelegation (your second jboss-web.xml), bundle your Hibernate JARs into your app and add the following properties to your persistence.xml (to "avoid" the issue you're facing):

<property name="hibernate.validator.apply_to_ddl">false</property>
<property name="hibernate.validator.autoregister_listeners">false</property>

One user reported this didn't work for him.

Option 2

Disable java2ParentDelegation (your second jboss-web.xml), bundle your Hibernate JARs into your app and override the hibernate-validator JARs in common/lib.

I'm not able to explain why the hibernate-validator from commons/lib still gets picked.

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