We are currently migrating our Java EE application from Weblogic 11g to Weblogic 12c.
Here were are facing ClassCastException when using JPA EntityManager's query.getSingleResult() method.
It seems to be the Object returned by entityManager is loaded by different classloader and the Object in Application is loaded by different classloader were the classes are same.
While checking with wls-cat in weblogic it shows Same classloader with multiple instance for single application.
Error: Caused By: java.lang.ClassCastException: Cannot cast com.dev.user.dataaccess.jpa.entity.User to com.dev.user.dataaccess.jpa.entity.User
Can someone help me to resolve it? Thanks in Advance.
UPDATED: After some workaround found that Persistence.XML is loaded on Application deployement so entitymanager loads the classes declared in persistnce.xml . When we redeploy our application uses new classloader but entitymanager still uses the old classloader.
