users@glassfish.java.net

Weird classcast exception..

From: Nick Stuart <nicholas.stuart_at_gmail.com>
Date: Tue, 13 Nov 2007 10:26:01 -0500

Hi all, have an oddity here. We are seeing the following error when using
the following.
List<MyObject> objects = <whatever>
object.toArray(new MyObject[0]); //used to get a typed array back.

The problem is that we get the following error:
>Cannot cast an instance of
"class MyObject (loaded by instance of
org.apache.catalina.loader.WebappClassLoader(id=3))" to an instance of
"class MyObject (loaded by instance of
org.apache.catalina.loader.WebappClassLoader(id=183))"<

The only thing that is maybe kind of odd (but not really) is that these
objects are coming out of the session. This happens all within 2 or 3
requests/pages so the session and everything else is the same and the server
hasn't been restarted or anything like that.

So how would we be getting 2 different class loaders here? All the objects
are created with in the same web app and everything else. We don't have this
class outside of the web app either.

Any ideas? We can obviously get around this, but thought it was kind of odd.
-Nick