• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

EclipseLink – javax.persistence.PersistenceException : No Persistence provider for EntityManager

February 19, 2014 //  by Amr Mohammed

This post provides possible exception while doing the JPA programming and the suggested solution for resolving the exception. This post will solve the issue that can be happened while the JPA implementation trying to get a persistence provider. The exception explained in this post thrown when you have not configured properly the persistence unit name in the persistence.xml.

Look at the following example:

EntityManagerFactory factory = Persistence.createEntityManagerFactory("EclipseLink-JPA-Installation");
<span style="font-size: 12px; line-height: 18px;">


When we are coming to execute an application contains the above snippet of code, we might got the following persistence exception:

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named EclipseLink-JPA-Installation
 at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
 at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
 at net.javabeat.eclipselink.JPAImpl.main(JPAImpl.java:12)
<span style="font-size: 12px; line-height: 18px;">


Such that exception notify you for reviewing the persistence.xml file that located under META-INF which in turn located under your source code. Check your persistence-unit name, you almost probably have a wrong name of the persistence unit or you have no persistence at all.

If you have a persistence unit in the persistence.xml, you have make sure that the persistence unit name is identical to the name that is passed into createEntityManagerFactory method. But if you have no persistence unit at all, you have to create it.

Note : The exception solution is only the possible, it is common that same exception could be thrown for multiple reasons which is not explained in this tutorial. If you come across any such scenario, please write it in the comments section.

To know more about how to create EclipseLink and JPA project, please read our previous tutorial eclipselink jpa installation and configuration.

 

Category: Java EETag: EclipseLink, JPA

About Amr Mohammed

Previous Post: « EclipseLink – JPA Fields Annotations – @Basic and @Transient
Next Post: JSTL Core c:remove Tag »

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

How to Implement getActiveCount() Method of ThreadPoolExeceutor in Java

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact