Re: Servlet Problems!

wplatzer@iaik.tu-graz.ac.at writes:

> 
> I modified Jigsaw to set additional parameters for a request:
> 
> import test.TestClass;
> 
>   TestClass t = new TestClass();
>   request.setState("test.test_class", t);
> 
> 
> and then I wrote a servlet:
> 
>      TestClass tc = (TestClass)req.getAttribute("test.test_class");
> 
> But this line always causes a ClassCastException. If I write
> 
>     Object o = req.getAttribute("test.test_class");
>     System.out.println(o.getClass().getName());
> 
> I get
> 
>     test.TestClass.
> 
> It seems that Servlets use another ClassLoader than Jigasaw. Is this a
> general Problem with Servlets or is this problem specific to Jigsaw?
> If I use java.lang.String instead of test.TestClass there is no
> ClassCastException. Why?
> 
> Can someone explain this?

 I see. Yes Servlets are loaded with a specific ClassLoader (LocalServletLoader)
 that allows auto reload when the servlet class is modified. But the 
 ClassLoader used for system classes is the default classloader, that's the 
 reason why there is no ClassCastException for String. 

 We haven't thought about that, so we have to find a solution. May be we could
 use the LocalClassLoader only for the servlet class (and not for embedded 
 classes) but this could create other problems, I have to think about that.

 Benoit.

- Benoît Mahé -------------------------------------------------------
                      World Wide Web Consortium (W3C)
                    Architecture domain - Jigsaw Team           

  http://www.w3.org/People/Mahe - bmahe@w3.org - +33.4.92.38.79.89 
---------------------------------------------------------------------

Received on Wednesday, 15 April 1998 08:16:51 UTC