The collection of metamodel types is empty

I'm have a maven project with JPA and EclipseLink. When I run it don't generate the tables in the database. I have this output:
The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
IceCreamShop/src/main/resources/META-INF/persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<
persistence version="3.2" 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_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.Invoice</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.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<
persistence version="3.2" 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_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.Invoice</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.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
16 Replies
JavaBot
JavaBot3w 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$#OP3w ago
All of my classes have a similar mapping:
package org.logic;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;

@Entity
public class Action implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private int act_id;


@Column(unique=true)
private String action;

@ManyToMany
private List<Role> roles;

//Contructors, getters and setters, etc.
package org.logic;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;

@Entity
public class Action implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private int act_id;


@Column(unique=true)
private String action;

@ManyToMany
private List<Role> roles;

//Contructors, getters and setters, etc.
pom.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>4.0.5</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>4.0.5</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>4.0.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>4.0.4</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>4.0.4-RC1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.13</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>4.0.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>4.0.4</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>4.0.4-RC1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.13</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>
Adding
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
to persistence.xml don't solve it, neither with true
dan1st
dan1st3w ago
Can you show your main class? or whatever creates the EntityManagerFactory What IDE are you using?
dan1st
dan1st3w ago
according to https://www.eclipse.org/forums/index.php/t/365263/, the warning shouldn't matter if you don't use the criteria API
Eclipse Community Forums: EclipseLink » The collection of metamodel...
The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks.
dan1st
dan1st3w ago
What happens if you just try to insert an element into the DB from your application? I think it might only create the tables when you execute something or you could try these properties:
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
.
Franscis123$#
Franscis123$#OP3w ago
package org.logic;

import org.persistence.PersistenceController;

public class Main {

public static void main(String[] args) {

PersistenceController PerCtrl = new PersistenceController();

}

}
package org.logic;

import org.persistence.PersistenceController;

public class Main {

public static void main(String[] args) {

PersistenceController PerCtrl = new PersistenceController();

}

}
package org.persistence;

public class PersistenceController {

ActionJpaController ActJpaCtrl = new ActionJpaController();
FlavorJpaController FlvJpaCtrl = new FlavorJpaController();
Ice_CreamJpaController IceJpaCtrl = new Ice_CreamJpaController();
InvoiceJpaController InvJpaCtrl = new InvoiceJpaController();
OrdenJpaController OrdJpaCtrl = new OrdenJpaController();
RoleJpaController RolJpaCtrl = new RoleJpaController();
SizeJpaController SizJpaCtrl = new SizeJpaController();
UserJpaController UsrJpaCtrl = new UserJpaController();


}
package org.persistence;

public class PersistenceController {

ActionJpaController ActJpaCtrl = new ActionJpaController();
FlavorJpaController FlvJpaCtrl = new FlavorJpaController();
Ice_CreamJpaController IceJpaCtrl = new Ice_CreamJpaController();
InvoiceJpaController InvJpaCtrl = new InvoiceJpaController();
OrdenJpaController OrdJpaCtrl = new OrdenJpaController();
RoleJpaController RolJpaCtrl = new RoleJpaController();
SizeJpaController SizJpaCtrl = new SizeJpaController();
UserJpaController UsrJpaCtrl = new UserJpaController();


}
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();
}
dan1st
dan1st3w ago
you create a new EntityManagerFactory for each entity class/controller? normally you should have one EntityManagerFactory for your application e.g. you could create it in PersistenceController
Franscis123$#
Franscis123$#OP3w ago
I created a JpaController class for each class
dan1st
dan1st3w ago
yeah but you don't need to create EntityManagerFactorys in each of these controllers
Franscis123$#
Franscis123$#OP3w ago
IntelliJ IDEA Community
dan1st
dan1st3w ago
. . .
Franscis123$#
Franscis123$#OP3w ago
I don't tried it because I don't have tables in my database Also I used NetBeans only to generate the JpaControllers, because IntelliJ Community don't have these options with premium, and it generate one for each class.
dan1st
dan1st3w ago
try it and see what happens I guess
Franscis123$#
Franscis123$#OP3w ago
How could create the EntityManagerFactory in the Persistence Controller?
dan1st
dan1st3w ago
package org.persistence;

public class PersistenceController {

private final EntityManagerFactory emf = Persistence.createEntityManagerFactory("IceCreamShopPU");

final ActionJpaController actJpaCtrl = new ActionJpaController(emf);
final FlavorJpaController flvJpaCtrl = new FlavorJpaController(emf);
final Ice_CreamJpaController iceJpaCtrl = new Ice_CreamJpaController(emf);
final InvoiceJpaController invJpaCtrl = new InvoiceJpaController(emf);
final OrdenJpaController ordJpaCtrl = new OrdenJpaController(emf);
final RoleJpaController rolJpaCtrl = new RoleJpaController(emf);
final SizeJpaController sizJpaCtrl = new SizeJpaController(emf);
final UserJpaController usrJpaCtrl = new UserJpaController(emf);


}
package org.persistence;

public class PersistenceController {

private final EntityManagerFactory emf = Persistence.createEntityManagerFactory("IceCreamShopPU");

final ActionJpaController actJpaCtrl = new ActionJpaController(emf);
final FlavorJpaController flvJpaCtrl = new FlavorJpaController(emf);
final Ice_CreamJpaController iceJpaCtrl = new Ice_CreamJpaController(emf);
final InvoiceJpaController invJpaCtrl = new InvoiceJpaController(emf);
final OrdenJpaController ordJpaCtrl = new OrdenJpaController(emf);
final RoleJpaController rolJpaCtrl = new RoleJpaController(emf);
final SizeJpaController sizJpaCtrl = new SizeJpaController(emf);
final UserJpaController usrJpaCtrl = new UserJpaController(emf);


}
ping since it's been some time since you wrote that
JavaBot
JavaBot3w 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?