2

I have this strange error when deploying my application , but the jar needed is in my POM file !!!

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.4.Final</version>
</dependency> 

Here the error:

 Error creating bean with name 'entityManagerFactory' defined in class path resource [fr/telecom/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/MetadataBuilder

I even check the war and the jar is inside the war

enter image description here

Searching Ctrl + Shift + T I found:

org.hibernate.validator.internal.metadata.aggregated.MetaDataBuilder

and

org.hibernate.boot.MetadataBuilder 
3
  • NoClassDefFoundError isn't saying that class is not present. It's saying a dependency of that class is not found in the CLASSPATH. So look at the source for that class and see what it needs Commented Dec 1, 2015 at 19:50
  • Also depending on your IDE and project setup, you may need to execute some sort of "refresh" operation. In some projects with multiple pom files, for example, a rebuild of the full project would be required to fix dependency issues. Commented Dec 1, 2015 at 20:06
  • When you do a Ctrl + Shift + T (Open Type) in your Eclipse and search for MetadataBuilder, how many do you get? Commented Dec 2, 2015 at 7:59

2 Answers 2

1

You are using the wrong version. org.hibernate.boot.MetadataBuilder is available in version 5:

$ jar tvf ~/.m2/repository/org/hibernate/hibernate-core/5.0.4.Final/hibernate-core-5.0.4.Final.jar | grep MetadataBuilder

3931 Wed Nov 18 12:22:14 CET 2015 org/hibernate/boot/MetadataBuilder.class

In version 4.3.6.Final, it's defined in another package:

$ jar tvf ~/.m2/repository/org/hibernate/hibernate-core/4.3.6.Final/hibernate-core-4.3.6.Final.jar | grep MetadataBuilder

672 Wed Jul 16 16:28:14 CEST 2014 org/hibernate/metamodel/MetadataBuilder.class
Sign up to request clarification or add additional context in comments.

Comments

0

1) The head of you DTD in hibernate.config.xml must be the following:

`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"classpath:/org/hibernate/hibernate-configuration-3.0.dtd">

`

2) if you have you hibernate.config.xml in /WEB-INF remove it and place in /src/main/resources;

3) Finally, you will have to ovewrite some lines in web.xml file where you invoke the hibernate to be as the following:

`<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>   
        classpath:hibernate.cfg.xml                     
        </param-value>
    </context-param>`

I Hope it halps. Herman, Mozambique

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.