why getting “No Persistence provider for EntityManager” when running with jnlp while standalone jar works fine

Environment Win 8.1 MySQL server: localhost Netbeans 7.4 Java: 1.7.0_51 (J2SE) JRE: 1.7.0_51-b31 EclipseLink(JPA 2.1)

There are several posts asking about this “no persistence provider for EntityManager named…” error. I am developing with J2SE (not J2EE). However, my problems seem silly but it really troubles me for 2days. Is it that I need some other software for this standalone program to work? But why is it oaky when I run the program under Netbeans IDE? Is it some sort of environment setting issue which I failed to try?

Working snapshot and EclipseLink message!

I use Netbeans to write code, and it runs okay. Now, I decided to copy the whole standalone package out “D:\NetBeansWork\ProjCostTracking\dist”. I have change the security setting to medium in Java Control Panel. Then, I double-clicked on ProjCostTracking.jnlp to launch. Well, this is what I see.

this is my persistence.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
      <persistence-unit name="ProjCostTrackingPU" transaction-type="RESOURCE_LOCAL">
          <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/biotechcost?zeroDateTimeBehavior=convertToNull"/>
          <property name="javax.persistence.jdbc.password" value="1234"/>
          <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
          <property name="javax.persistence.jdbc.user" value="root"/>

The entity files are

The generated files and lib

As for persistence.xml, I copy to 3 places just to make sure it can be “seen”.

As for CLASSPATH, I copied the required jar files (from ProjCostTracking\dist\lib) to lib folder under my default JDK and JRE. So java suppose to see the jars.


Usually this is a connector issue. It seems that eclipse is not using the right connector. Check the connector version. It should match with the version of your MySQL database.

I guess I am using JNLP in a wrong way. Because when I run the standalone with "java -jar myprogram.jar" it works perfectly, no error. But, when I use jnlp it gives me the error. Hope I am not misleading everyone here. It is more related to how jnlp works with the persistence stuff.

The Problem is that if you want to use Application Managed Entity Manager you have to control the scope of the drivers and used APIs.

For example: in a Java SE Application you can build the project with maven. The Scope of the dependencies signals when the API or the package has to be used. E.g.


Because the life circle is managed by the application and not by the container (like in Java EE applications). In my case it was important to change the scope from provided to runtime (Same with the database driver). In your case - if you are not using maven you are dependent what the JVM is using.

Maybe this is helpful. I know this kind of issues and it is really annoying :|

Maven Scope Doc

Need Your Help

Control "Notification Centre" settings for iPad app (using Phonegap)

objective-c cordova ios7 push-notification nsnotificationcenter

Have developed an iPad app using Phonegap that works well along with Push Notifications in iOS 7. But my question is whether there is a possibility to control/modify iOS "Notification Centre" setti...

Accordion menu with javascript link issue

javascript jquery css accordion

I made this list accordion menu in javascript with a tutorial.