Hello,

I am experiencing a problem with Tomcat and class hierarchies.  In
particular when an object (which implements interface X) is shared among
serveral contexts I am unable to cast the object back into interface X.

Here is the setup (for simplicity I'll illustrate this with 2 contexts):

* Interface "ClassInterface" is distributed across all applications in a
.jar.

Application A in context a
--------------------------
- Implements ClassInterface and adds an instance of the class in it's
context:

  ClassInterface i = new ClassInterfaceImplementation();
  getServletContext().setAttribute("some.key", i);

Application B in context b
--------------------------
- Tries to cast the object in the context back into a ClassInterface but
fails with a classCastException: ClassInterfaceImplementation

  ServletContext context = (ServletContext)
getServletContext.getContext("/a");
  ClassInterface i = (ClassInterface) context.getAttribute("some.key");
  -- EXCEPTION IS THROWN --
  java.lang.ClassCastException: ClassInterfaceImplementation


Has anybody experienced this before?  Does setting an attribute in the
context mess things up with the class hierarchy?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to