Home entityManagerFactory NoClassDefFoundError
Reply: 2

entityManagerFactory NoClassDefFoundError

Bartłomiej Matyjaszczyk
1#
Bartłomiej Matyjaszczyk Published in 2018-01-10 19:19:16Z

I'm doing simple api with Spring Boot and embeeded database and it's hits me an

NoClassDefFoundError. : Error creating bean with name 'entityManagerFactory'

Maybe you know which dependency I should include to my pom.xml. Maven project. here is what i have:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError:

Maciej Kowalski
2#
Maciej Kowalski Reply to 2018-01-10 20:35:08Z

1) Make sure none of your dependencies (except spring-boot-starter-data-jpa) have inclusive dependency to hibernate-core. Otherwise libraries may get clashed.

2) You may also need to add this artifact:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
</dependency>

Version should be inferred.

ootero
3#
ootero Reply to 2018-01-10 22:08:53Z

hibernate-core and hibernate-entitymanager are being transitively included via spring-boot-starter-data-jpa

Edited: Could you first try removing you local .m2/repository? Sometime it gets corrupted.

rm -rf ~/.m2/repository

Could you include which Spring Boot version are you using pom.xml content.

Could you also include you data source and JPA properties?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.362246 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO