snip
>A class is *not* (common mistake) defined by name, but by name + loader.
>Lack of this knowledge is what leads to a lot of ClassCastException
>questions
>in various forums. The serializer does not have a problem finding the class,
>it simply does object.getClass(), the deserializer however needs to know
>exactly
>which loader to load from (since it gets the name from the stream but is
>still missing
>the loader info).
>snip
>Note that the above list is simplified but it demonstrates the general
>principle. In reality it is a tree - not a list, and each
>loader is a node. My recommendation is to put TunnelServlet at the
>Servlet/Beans level (usually where it belongs) and
>to put the beans either in the same loader or a parent (lower) loader than
>the servlet. If you dont want to do this
>then supply (thru some means) the TunnelServlet with the loader it's
>supposed to use and override ObjectInputStream's
>resolveClass() method to find it (somewhat more complicated).
so would the following work?
TunnelServlet is an abstract base class and is always extended by some
class that has access to all the classes it needs to know for
serialization. so i can simply get the classloader of the extending class
within TunnelServlet by getClass().getClassloader() and use that for my own
ObjectInputStream class that overrides resolveClass() with a call to
loadClass using that classloader.
seems the simplest and most appropriate solution to me (as a novice to
classloader issues).
what do you think?
thanks,
robert
(-) Robert Kr�ger
(-) SIGNAL 7 Gesellschaft f�r Informationstechnologie mbH
(-) Br�der-Knau�-Str. 79 - 64285 Darmstadt,
(-) Tel: 06151 665401, Fax: 06151 665373
(-) [EMAIL PROTECTED], www.signal7.de