I am using a REST-Service with JPA and every second time I am running the project I get a ClassCastExeption (from a NamedQuery Result). It always works the first time after restarting the Server (Glassfish 4.1.1).
I tried if the problem only occurs with a specific class but it fails to cast no matter what class i get from JPA (after second start of the project).
User u = em.createNamedQuery("getUserByUUID", User.class)
.setParameter("uuid", uuid)
.setParameter("deleted", false)
.getSingleResult();
return (User) u;
Error Message:
java.lang.ClassCastException: de.edvschuleplattling.evt.eventmonitoring.dto.User cannot be cast to de.edvschuleplattling.evt.eventmonitoring.dto.User