2011-07-28 37 views
4

我想部署一個Web應用程序使用休眠到Jboss 4.3.2.GA但我收到以下錯誤。嘗試部署一個Web應用程序使用最新的休眠版本jboss4.2.3.GA

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) 

我在/ WEB-INF 一 「的jboss-web.xml中」 爲

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

,但我仍然有同樣的錯誤

回答

3

我增加了以下依賴性,我的問題就解決了。感謝Hibernate的人,他們爲我們提供了一個傳統的驗證器。

<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> 
+0

你的帖子/答案告訴了我一些我不知道你可以用JBoss做的事情,並解決了它帶來的問題。非常感謝您發佈此信息。 – Brendan

1

長話短說。你不能在JBoss 4.2.3上使用最新的Hibernate版本(3.5+),因爲4.2.3中的Hibernate依賴和EJB JAR之間存在干擾。你有3種選擇:

  • 使用附帶的4.2.3,並且不與EJB的JAR干擾休眠
  • 使用JBoss的早期版本不具有休眠(如4.0.2)
  • 使用JBoss的後續版本,其具有休眠
  • 較新版本的