0

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.

added wls-cat classloader image

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.

3
  • How have you deployed the application and what is in its packaging? Ie do you have the JPA provider jars in the application and on the server multiple times? Do you use hot redeployment, and if so, does restarting the server help? Commented Aug 8, 2023 at 16:49
  • We are using EAR for deployment. Yes we do have JPA jars. No We not do hot redeployement. Commented Aug 8, 2023 at 17:25
  • More meant where the jars are and if any are included in the ear that might also be on the server's class path. Commented Aug 8, 2023 at 19:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.