Alex Rivera | Logout

How to cast two instance of the same loaded different classloader?

Asked 2012-05-13T07:13:23.713
11

I have two different webapps, and each load the same class A with different classloader. When I put one instance in the session and then get it from the other webapp, a ClassCastException is thrown.

For example, in webapp A, I store a in the session, then in webapp B, I get the a from the session and cast it to A, the ClassCastException is thrown.

Is there a way to resolve this?

Edit
Report

1 Answer

1

You can't. Two classes loaded by different classloaders are different.

answered 2012-05-13T08:23:18.940

Your Answer