4

I am trying to deploy a web application using hibernate to Jboss 4.3.2.GA but I am receiving following error.

Invocation of init method failed; nested exception is
org.hibernate.AnnotationException:
java.lang.NoSuchMethodException:
org.hibernate.validator.ClassValidator.<init>(
   java.lang.Class,
   java.util.ResourceBundle,
   org.hibernate.validator.MessageInterpolator,
   java.util.Map,
   org.hibernate.annotations.common.reflection.ReflectionManager)

I have a "jboss-web.xml" in /WEB-INF as

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <loader-repository>
    <loader-repository-config>
    java2ParentDelegation=false
    </loader-repository-config>
    </loader-repository> 
 </jboss-web>

but i am still having the same error

dursun
  • 1,861
  • 2
  • 21
  • 38

2 Answers2

3

I have added following dependencies and my problem is solved. Thanks to Hibernate guys, they provide us a legacy validator.

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator-legacy</artifactId>
        <version>4.0.2.GA</version>
        <exclusions>
            <exclusion>
                <artifactId>hibernate-commons-annotations</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
        </exclusions>
    </dependency>
dursun
  • 1,861
  • 2
  • 21
  • 38
  • Your post/answer taught me some things I didn't know you could do with JBoss AND solved the issue that comes with it. Thank you so much for posting this. – Brendan Sep 19 '11 at 14:56
1

Long story short. You can't use the latest Hibernate version (3.5+) with JBoss 4.2.3, as there is interference between Hibernate dependencies and EJB JARs in 4.2.3. You have 3 choices:

  • Use the Hibernate which ships with 4.2.3 and doesn't interfere with the EJB JARs
  • Use an earlier version of JBoss which doesn't have Hibernate (like 4.0.2)
  • Use a later version of JBoss which has a newer version of Hibernate
atrain
  • 9,139
  • 1
  • 36
  • 40