W3C home > Mailing lists > Public > www-jigsaw@w3.org > March to April 1998

Re: Servlet Problems!

From: Wolfgang Platzer <wplatzer@iaik.tu-graz.ac.at>
Date: Wed, 15 Apr 1998 14:22:26 +0200
Message-ID: <010e01bd6869$267d42c0$1cea1b81@kopernikus.iaik.tu-graz.ac.at>
To: "Benoit Mahe" <Benoit.Mahe@sophia.inria.fr>
Cc: "Jigsaw Mailinglist" <www-jigsaw@w3.org>
In my servlet now I use a workaround:

String tcs = (String)req.getAttribute("test.test_class");
TestClass tc = new TestClass(tcs);


The reloading of a changed servlet works great!!!

I suggest only to reload the classes in the servlets directory and NOT to
reload classes which are defined in Jigsaw's classpath.

Wolfgang


-----Ursprüngliche Nachricht-----
Von: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>
An: Wolfgang Platzer <wplatzer@iaik.tu-graz.ac.at>
Cc: Jigsaw Mailinglist <www-jigsaw@w3.org>
Datum: Mittwoch, 15. April 1998 14:18
Betreff: 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:24:22 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:27 GMT