I’m trying to add hibernate to my spring project for database persistence, I’ve downloaded hibernate 4.1.6 the latest stable version and I’m using spring 3.1.
However when I try and run my project I get:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0':
Invocation of init method failed; nested exception is java.lang.ClassFormatError:
Absent Code attribute in method that is not native or abstract in class file
javax/validation/Validation
The external jars I’ve added to my project so far are:
antlr-2.7.7.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.6.Final.jar
hibernte-jpa-2.0-api-1.0.1.Final.jar
javassist-3.15.0-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
hibernate-entitymanager-4.1.6.Final.jar
slf4j-api-1.6.1.jar
My pom.xml contains the following dependencies:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<scope>runtime</scope>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
Thanks for your help, any alterations that should be made to my question please let me know.
Daniel
There seems to be a problem with
javaee-apidependency in the Maven repository, as a solution you can switch to alternative onesCredits: This solution is discussed here.
See also Failed to load ApplicationContext with @ContextConfiguration(classes={ … }) and JUnit testcase passes with eclipse but fails with maven build
update It’s not understood why you have downloaded separate hibernate jar files(including JPA 2.0 implementation) if you have Hibernate entity manager and Java EE dependencies in your pom.xml