No Persistence provider for EntityManager named IceCreamShopPU

Jan 30, 2025 9:51:12 AM jakarta.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log
WARNING: jakarta.persistence.spi::No valid providers found.
Exception in thread "main" jakarta.persistence.PersistenceException: No Persistence provider for EntityManager named IceCreamShopPU
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:96)
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:66)
at org.persistence.ActionJpaController.<init>(ActionJpaController.java:17)
at org.persistence.PersistenceController.<init>(PersistenceController.java:5)
at org.logic.Main.main(Main.java:9)
Jan 30, 2025 9:51:12 AM jakarta.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log
WARNING: jakarta.persistence.spi::No valid providers found.
Exception in thread "main" jakarta.persistence.PersistenceException: No Persistence provider for EntityManager named IceCreamShopPU
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:96)
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:66)
at org.persistence.ActionJpaController.<init>(ActionJpaController.java:17)
at org.persistence.PersistenceController.<init>(PersistenceController.java:5)
at org.logic.Main.main(Main.java:9)
ActionJpaController:
package org.persistence;

import jakarta.persistence.*;
import java.io.Serializable;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import org.logic.Role;
import java.util.ArrayList;
import java.util.List;
import org.logic.Action;
import org.persistence.exceptions.NonexistentEntityException;

public class ActionJpaController implements Serializable {

public ActionJpaController(EntityManagerFactory emf) { this.emf = emf; }

public ActionJpaController(){ emf = Persistence.createEntityManagerFactory("IceCreamShopPU"); }

private EntityManagerFactory emf = null;

public EntityManager getEntityManager() { return emf.createEntityManager(); }
package org.persistence;

import jakarta.persistence.*;
import java.io.Serializable;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import org.logic.Role;
import java.util.ArrayList;
import java.util.List;
import org.logic.Action;
import org.persistence.exceptions.NonexistentEntityException;

public class ActionJpaController implements Serializable {

public ActionJpaController(EntityManagerFactory emf) { this.emf = emf; }

public ActionJpaController(){ emf = Persistence.createEntityManagerFactory("IceCreamShopPU"); }

private EntityManagerFactory emf = null;

public EntityManager getEntityManager() { return emf.createEntityManager(); }
21 Replies
JavaBot
JavaBot3mo ago
This post has been reserved for your question.
Hey @Franscis123$#! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Franscis123$#
Franscis123$#OP3mo ago
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" 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_2.xsd">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="javax.persistence.jdbc.user" value="admin"/>
<property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" 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_2.xsd">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="javax.persistence.jdbc.user" value="admin"/>
<property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
dan1st
dan1st3mo ago
You are using javax.persistence in your persistence.xml but you are using Jakarta EE so you need jakarta.persistence and you also need to update the xmlns etc try something like
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="jakarta.persistence.jdbc.user" value="admin"/>
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="jakarta.persistence.jdbc.user" value="admin"/>
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
Franscis123$#
Franscis123$#OP3mo ago
I need jakarta.ee dependencies or something? I build the proyect with NetBeans and throws this:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project IceCreamShop: Fatal error compiling: java.lang.RuntimeException: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.7.12.v20230209-e5c4074ef3): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {https://jakarta.ee/xml/ns/persistence}persistence was not found in the project
-> [Help 1]
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project IceCreamShop: Fatal error compiling: java.lang.RuntimeException: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.7.12.v20230209-e5c4074ef3): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {https://jakarta.ee/xml/ns/persistence}persistence was not found in the project
-> [Help 1]
dan1st
dan1st3mo ago
Did you use that exact persistence.xml? Can you show your pom.xml?
Franscis123$#
Franscis123$#OP3mo ago
Yes
dan1st
dan1st3mo ago
including the xmlns="https://jakarta.ee/xml/ns/persistence"?
Franscis123$#
Franscis123$#OP3mo ago
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
dan1st
dan1st3mo ago
I meant the xmlns="https://jakarta.ee/xml/ns/persistence" in the persistence.xml and the full pom.xml
Franscis123$#
Franscis123$#OP3mo ago
I will send pom.xml by parts, is so long for a single message yes, xmlns is same than this in my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org</groupId>
<artifactId>IceCreamShop</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.asm</artifactId>
<version>9.4.0</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org</groupId>
<artifactId>IceCreamShop</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.asm</artifactId>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.antlr</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<exec.mainClass>org.icecreamshop.IceCreamShop</exec.mainClass>
</properties>
</project>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.antlr</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<exec.mainClass>org.icecreamshop.IceCreamShop</exec.mainClass>
</properties>
</project>
dan1st
dan1st3mo ago
I assume updating Eclipse persistence to 4.0.5 doesn't make a difference?
Franscis123$#
Franscis123$#OP3mo ago
I can change the version directly in the xml code? If I can, what dependency is?
dan1st
dan1st3mo ago
all that are 2.7.12
Franscis123$#
Franscis123$#OP3mo ago
I updated Eclipse persistence to 4.0.5 but I still with this error In my main I only have this:
PersistenceController PerCtrl = new PersistenceController();
PersistenceController PerCtrl = new PersistenceController();
dan1st
dan1st3mo ago
Do you have any <plugins> in your pom.xml? Can you show your exact persistence.xml? Where exactly did you put that file?
Franscis123$#
Franscis123$#OP3mo ago
IceCreamShop/src/main/resources/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="jakarta.persistence.jdbc.user" value="admin"/>
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="jakarta.persistence.jdbc.user" value="admin"/>
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
No, I don't have
dan1st
dan1st3mo ago
What if you do that?
<?xml version="1.0" encoding="UTF-8"?>
<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_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="jakarta.persistence.jdbc.user" value="admin"/>
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<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_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="IceCreamShopPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.logic.Action</class>
<class>org.logic.Flavor</class>
<class>org.logic.Ice_Cream</class>
<class>org.logic.Orden</class>
<class>org.logic.Role</class>
<class>org.logic.Size</class>
<class>org.logic.User</class>
<properties>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/IceCream?serverTimezone=UTC"/>
<property name="jakarta.persistence.jdbc.user" value="admin"/>
<property name="jakarta.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.password" value="+V$u]"/>
<property name="jakarta.org.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
would be weird though or alternatively with
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="4.0">
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="4.0">
Franscis123$#
Franscis123$#OP3mo ago
The same error This is incomplete or is just that? I put it before <persistence-unit> and marks it as wrong
dan1st
dan1st3mo ago
I just copied the <persistence> there
JavaBot
JavaBot3mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?