-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello, I'm trying to retrieve an object from the session in the following way:
User loggedUser = (User) Executions.getCurrent().getSession().getAttribute( Constants.LOGGED_USER );
but I'm getting a ClassCastException at runtime saying I can't cast User to User. If I remove the cast in the code, I get a type mismatch at compile time.
I've tried to write:
Object test = Executions.getCurrent().getSession().getAttribute( Constants.LOGGED_USER );
log.info("user from session: " + test.getClass().getName());
And test is of type User.
How could I exit this deadlock? Thank you. Regards.
Could you make sure both User
belong to the same package? Maybe one is abc.User
and another is def.User
.
Maybe 2 User
classes are created by different classloaders?
see https://stackoverflow.com/questions/11865917/classcastexception-because-of-classloaders
Asked: 2022-08-17 00:04:14 +0800
Seen: 5 times
Last updated: Aug 17 '22