No [EntityType] was found for the key class [...] in the Metamodel

The problem is your hot deploying of your application. The old persistence unit is sticking around in the server because you never closed the old factory, so after the hot deploy the factory still has the old classes, so you get the class cast error.

You need to clear out the old persistence unit. Closing the EntityManagerFactory should do this, such as in a Servlet destroy callback.

If you use a managed persistence unit, then everything should get cleaned up automatically. The issue is in how you are managing your persistence unit.

I think there is also a bug for this logged on EclipseLink, you might want to vote for that bug.


Can you add the classes manually to the persistence.xml? Ideally, you shouldn't have to do this, but it would at least give you a start.

<persistence-unit><class>com.maze.model.UserAccount</class>...


I once encountered a similar problem. The exception was sometimes thrown, sometimes not. After a painful amount of time debugging I found out it was caused by a second persistence.xml file (containing a persistence unit with an identical name) included in another jar on the classpath.