Clay Banks
Clay Banks

Reputation: 4581

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?

Upvotes: 11

Views: 40506

Answers (1)

Clay Banks
Clay Banks

Reputation: 4581

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

Upvotes: 17

Related Questions