Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Unknown Entity bean class after hot-deploy
Every time that I do redeploy (on Netbeans) Eclipselink stops working. I have to restart Glass to make it work again.
ava.lang.IllegalArgumentException: Unknown Entity bean class: class com.traslado.modelo.Usuario, please verify that this class has been marked with the @Entity annotation.
There is an old reply to this in Stackoverflow:
The issue is the old persistence unit with references to the old classes is remaining after your redeploy. Ensure the old EntityManagerFactory is getting closed. Glassfish should handle this for any managed factories such as in a SessionBean, but if you are managing your own factories you need to ensure these are closed.
but I couldn't figure it out
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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">
<persistence-unit name="trasladoPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>trasladoDataPU</non-jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
This is how I retrieve an EntityManager
public EntityManager getEntityManager() {
//return JPAContainerFactory.createEntityManagerForPersistenceUnit("trasladoPU");
HashMap properties = new HashMap();
properties.put(PersistenceUnitProperties.CLASSLOADER, getClass().getClassLoader());
emf = Persistence.createEntityManagerFactory("trasladoPU", properties);
return emf.createEntityManager();
}
No matter if I close the EMF after each EntityManager, the error is throws after every hot deploy