Usually, when I undeploy the cargotracker application, the following error appears in the server log:
SEVERE: The web application [/cargo-tracker] created a ThreadLocal with key of type [org.glassfish.pfl.dynamic.codegen.impl.CurrentClassLoader$1] (value [org.glassfish.pfl.dynamic.codegen.impl.CurrentClassLoader$1@18df5b39]) and a value of type [org.glassfish.web.loader.WebappClassLoader] (value [WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
I can then clean the project. Rebuilding generally succeeds the first time, too. But when I try to run it, deployment fails. Here is the relevant info from the server log:
INFO: Loading sample data.
INFO: Unloading all existing data.
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton SampleDataGenerator
...
Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
I have to stop and restart the database and server to be able to run the app again.