Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:10:36+00:00 2026-06-12T23:10:36+00:00

I have been searching for an answer during quite a long time before coming

  • 0

I have been searching for an answer during quite a long time before coming here and ask this question.
My problem is very simple : I cannot run any JUnit test when using the JPA Entity Manager API. It seems that my test is not reading the persistence.xml file.

When I call new Configuration().configure().buildSessionFactory(), it works like a charm but an exception is thrown when calling Persistence.createEntityManagerFactory("myapp") is:

javax.persistence.PersistenceException: No Persistence provider for
EntityManager named myapp at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at com.myapp.Test01.setUpBeforeClass(Test01.java:22)

My JavaSE project has the following structure :

myapp
++src/main/java
   ++com.myapp.model
      ++// My entity classes are here
++src/test/java
   ++com.myapp
      ++Test01.java
++src/main/resources
  ++hibernate.cfg.xml
  ++META-INF 
    ++persistence.xml

and persistence.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    version="2.0">
    <persistence-unit name="myapp" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"></property> 
        </properties>
    </persistence-unit>
</persistence>

Do you have any idea how to solve this issue ?

Thank you very much for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:10:37+00:00Added an answer on June 12, 2026 at 11:10 pm

    My guess would be that org.hibernate.ejb.HibernatePersistence is not on your classpath. That’s not in the main Hibernate jar, it’s in the hibernate-entitymanager or some such jar.

    A couple of quick experiments would be to do, in the code immediately before the call to Persistence.createEntityManagerFactory():

    System.out.println(getClass().getResource("META-INF/persistence.xml"));
    

    And:

    System.out.println(Class.forName("org.hibernate.ejb.HibernatePersistence"));
    

    It would also be wise to check that Eclipse is copying your resources; do a Project > Clean and then look in your Eclipse build output directory to see if persistence.xml is where you expect. I have sometimes run into cases where Eclipse doesn’t copy resources for some reason or other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching for an answer to this question for some time now,
I have been searching the internet wildly for an answer to this question. We
I have been searching desperately for an answer to this question, but not found
I have been searching for an answer to this question for days and it
I have been searching the answer to this question for a while. It seemed
I have been searching for an answer to this question but cannot find anything
I have been searching for an answer to this question but could not find
I have been searching everywhere for an answer to this question. I have an
This is my first question here. I have been searching Stack Overflow and other
I have been searching for an answer for quite some time, and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.