I am developing an application running on a glassfish v3 server using eclipelink as JPA provider.
When I use the autodeploy function to deploy a new version of my application, all Entity classes are not found anymore:
java.lang.IllegalArgumentException: Unknown entity bean class: class de.xxx.module.dwh.table.FedRawClick, please verify that this class has been marked with the @Entity annotation.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find( EntityManagerImpl.java:576)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find( EntityManagerImpl.java:460)
Yes, the class FedRawClick has an @Entity annotation.
After a restart of the domain everything is working fine again.
Also changes in the persistence.xml are ignored until I restart the domain.
Is this an eclipselink issue or an glassfish autodeploy issue?
Is there a Cache which can be flushed programmatically to solve this problem?
Looks like you are accessing a persistence unit outside of the container. Since it is not container managed, the application will need to call close on the factory when it is undeployed (or when it no longer needs the factory) so that it is released. It will not be cleaned up by finalize until the container is shut down.
Recently I also got the same problem and I also used
public void destruct()
in the web service that was fetching data from database using eclipseLink.
But to be on safer side, I also introduced a ServletContextListener Listener in my web application having public void contextDestroyed(ServletContextEvent event) method to close EntityManagerFactory in case web service's @PreDestroy public void destruct() was not able to close emf for any reason.
I have done to be on safer side because in the production server this issue happens then it will be very very critical because restarting the production server would mean all the applications running in the server will have to restarted.
So closing open emf in web service as well as in listener will make sure that application reployment wont require server re-start.