Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed

We Are Going To Discuss About Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed. So lets Start this Java Article.

Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed

  1. Error creating bean with name 'entityManagerFactory' defined in class path resource : Invocation of init method failed

    People using Java 9 include this dependency:
    <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version>

  2. Error creating bean with name 'entityManagerFactory' defined in class path resource : Invocation of init method failed

    People using Java 9 include this dependency:
    <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version>

Solution 1

I would start by adding the following dependency:

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

and

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.2.3.Final</version>
</dependency>

UPDATE: Or simply add the following dependency.

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

Original Author AchillesVan Of This Content

Solution 2

People using Java 9 include this dependency:

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

Original Author Rahul Jangra Of This Content

Solution 3

Adding dependencies didn’t fix the issue at my end.

The issue was happening at my end because of “additional” fields that are part of the “@Entity” class and don’t exist in the database.

I removed the additional fields from the @Entity class and it worked.

Goodluck.

Original Author JAD Of This Content

Solution 4

I’ve jdk-12.0.2.jdk, ‘ve found solution to the problem, add dependencies to pom.xml:

<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.25.0-GA</version>
</dependency>

Original Author Diego Santa Cruz Mendezú Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment