我有一個mavenized項目,我使用JSR 303(Bean驗證)。作爲參考實現,我使用Hibernate驗證器。在項目中,我指定了依賴關係:NoClassDefFoundError while using Hibernate-validator
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
<scope>provided</scope>
</dependency>
使用4.1.0版本時,所有工作都正常。但是當我將其更改爲4.2.0時。我得到這條線上運行時錯誤:
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/Persistence
......//more stack-trace
java.lang.NoClassDefFoundError: Could not initialize class com.andr.myproject.services.utils.ValidationUtils
在哪裏的問題?
UPD:我也使用Java-EE-5依賴,而不是6
UPD2:發生在JUnit測試這個錯誤
是的,它出現在'C:\ Users \ admin \ .m2 \ repository \ org \ hibernate \ hibernate-validator \ 4.2.0.Final' – MyTitle 2013-02-14 13:12:51
好的,看看jar中是否存在該類,如果是,請查看應用程序的啓動方式,看看它是否加載了正確的jar,這很大程度上取決於您如何啓動應用程序。 – comanitza 2013-02-14 13:19:13
看什麼課? 'com.andr.myproject.services.utils.ValidationUtils'這是我的課 – MyTitle 2013-02-14 13:22:38