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 915957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:58:23+00:00 2026-05-15T17:58:23+00:00

I am newbie with JPA. I’m trying to run some sample code using JPA

  • 0

I am newbie with JPA. I’m trying to run some sample code using JPA but I get the following exception:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyJPAApplicationPU

I put my exception message here,

INFO: Could not find any META-INF/persistence.xml file in the classpath
javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyJPAApplicationPU
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
        at com.myJpa.TestJPA.setUp(TestJPA.java:30)
        at com.myJpa.TestJPA.main(TestJPA.java:72)

Any help would be appreciated.

  • 1 1 Answer
  • 1 View
  • 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-05-15T17:58:23+00:00Added an answer on May 15, 2026 at 5:58 pm

    Well, the error is self explaining, you need to provide a META-INF/persistence.xml to use JPA. This file is used to define a “persistence unit”. From the JPA 1.0 specification:

    6.2.1 persistence.xml file

    A persistence.xml file defines a
    persistence unit. It may be used to
    specify managed persistence classes
    included in the persistence unit,
    object/relational mapping information
    for those classes, and other
    configuration information for the
    persistence unit and for the entity
    manager(s) and entity manager factory
    for the persistence unit. The
    persistence.xml file is located in
    the META-INF directory of the root
    of the persistence unit. This
    information may be defined by
    containment or by reference, as
    described below.

    Here is a sample persistence.xml for a Java SE environment (using Hibernate as JPA provider):

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      version="1.0">
        <persistence-unit name="MyJPAApplicationPU" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <class>com.mycompany.Foo</class>
            <class>com.mycompany.Bar</class>
            <exclude-unlisted-classes>true</exclude-unlisted-classes>
            <properties>
                <property name="hibernate.connection.provider_class" value="org.hibernate.connection.DriverManagerConnectionProvider" />
                <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:unit-testing-jpa"/>
                <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
                <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                <property name="hibernate.connection.username" value="sa"/>
                <property name="hibernate.connection.password" value=""/>
                <property name="hibernate.show_sql" value="true"/>
            </properties>
        </persistence-unit>
    </persistence>
    

    Some comments about the above file:

    • when running in a Java SE environment, you cannot rely on JTA and the transaction type must be RESOURCE_LOCAL (which is actually the default in a Java SE environment but specifying it make it more clear).
    • when running in a Java SE environment, you cannot use a JDNI data source and the provider will obtain connections directly from the JDBC driver so you must pass the relevant informations to the provider (driver class name, connection url, user, password). With JPA 1.0 the properties used to pass these metadata are provider specific.
    • To insure the portability of a Java SE application, it is necessary to explicitly list the managed persistence classes that are included in the persistence unit.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JPA/Hibernate (a newbie at them). When an exception occur (could be an
Newbie question since I'm not up to speed using maven at all. I'm trying
Newbie still learning, been trying to search and hack code together for hours now,
Newbie question here but for some reason I cant figure this out. I have
This seems like a common enough case, but as JPA newbie, I am having
Newbie question on drools. I am trying to access the following java class in
Newbie here. I'm trying to encrypt the user password using SHA-256 after they've made
Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
I am quite a newbie to Spring JPA in cooperation with ObjectDB database, but
Newbie question but I can't find the answer. On first run my app is

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.