Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider

I have the dependency defined in my pom.xml

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>3.3.0.ga</version>
</dependency>

I have the above jar in C:/User/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga

I've got a session-factory and datasource configured in a hibernate.cfg.xml and while trying to build the configuration in my main method:

Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory sessionFactory = configuration.buildSessionFactory(builder.build());
Session session = sessionFactory.openSession();

I get:

Exception in thread "main" java.lang.NoClassDefFoundError: 
    org/hibernate/annotations/common/reflection/MetadataProvider

I've tried adding the hibernate-commons-annotion jar straight in my Build Path as well as my WEB-INF/lib, but no luck yet

This is setup the same way and running properly on another application I've built, which didn't need the annotations jar imported. Any ideas?

like image 397
Clay Banks Avatar asked Sep 10 '14 00:09

Clay Banks


1 Answers

Apparently 3.3.0.ga was a 'mistake', had to update dependency to use 3.2.0.Final

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.2.0.Final</version>
    </dependency>

Source: https://hibernate.atlassian.net/browse/ANN-711

like image 51
Clay Banks Avatar answered Nov 12 '22 02:11

Clay Banks