Fw: ClassCastException while using getServlet(String servletName)

I am using Windows NT by the way.
A.    I do not see the auto Reload checkbox that you mention
B.    I think I have tried what you are mentioning. I am giving below the
steps that I carried out.
    1.  I created "Servlets" org.w3c.resources.DirectoryResource under
"Space" node
    2.  I added "org.w3c.jigsaw.servlet.servletDirectoryFrame" to the above
"Servlets" resource
    3.  I added "MxSessionManager" as resource of the type
"org.w3c.jigsaw.servlte.servletWrapper"
    4.  Under the "Attribute" tab of "MxSessionManager" resource, I
specified the class as
         "matrix.tenza.servlet.MxSessionManager.class", this is the full
package name. This class is
         available under the CLASSPATH "\matrix\javaclasses". There is no
other copy of
         MxSesssionManager.class in the whole system.
    5. I followed the steps 3 & 4 for "MxSessionHttp".
C. I went through the relevant Servlet java programs. From there I could
make out that Jigsaw tries to load
     the classes in the following way
     1. try to locate the class in the resource directory found in
servletDirectoryFrame.
      2. if not, read in the CLASSPATH string. Take care of classes present
by themselves as well as classess
           bundled inside jar and zip files.
D. As per the procedure I have listed out in B, C.2 should be taking place.

The problem is that the classes MxSessionManager, MxSessionHttp are being
loaded by different classloaders. I want them to be loaded by on
ClassLoader, preferably SystemLoader so that the objects of
the different servlets can be shared by each other. For e.g. Session related
information.

Thanks

Regards

S.Ramaswamy










-----Original Message-----
From: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>
To: S.Ramaswamy <srswamy@giasdl01.vsnl.net.in>
Cc: www-jigsaw@w3.org <www-jigsaw@w3.org>
Date: Tuesday, June 02, 1998 1:05 PM
Subject: Re: ClassCastException while usng getServlet(String)


"S.Ramaswamy" writes:

>
> I am using the following configuration
>
> a) Jigsaw Web Server from w3c Consortium that supports Servlets
> b) JDK1.2 beta 3
>
> I have two servlets
>
> 1)   MxSessionManager    servlet
> 2)  MxBrowse servlet
>
> User invokes MxSessionManager first. This gets inited allright. Then
> user invokes MxBrowse servlet. Within MxBrowse init method, I want the
> reference to MxSessionManager instance. MxSessionManager maintains
> session details which is required each and every subsequent servlet
> call. I am getting the referenc as given below
>
> ServletContext sc = conf.getServletContext();
> MxSessionManager sm =
> (MxSessionManager)sc.getServlet("MxSesssionManager");
>
> This gives me ClassCastException. I have checked the Class object of the
> returned object of getServlet("MxSessionManager").
> This is shown the same as MxSessionManager.
>
> Option 1 tried
> --------------------
> However, if I cast the returned value to HttpServlet, or GenericServlet
> the superclasses of MxSessionManager, then there is no
> ClassCastException.
>
> HttpServlet hs = (HttpServlet)getServlet("MxSessionManager");    //
> works fine
>
>
> Option 2 tried
> --------------------
>
> I have tried subclassing MxSessionManager say as MxLogin extends =
> MxSessionManager. Now I do
>
> MxSessionManager sm = (MxSessionManager)sc.getServlet("MxLogin");
>
> still no use.
>

Ok, I know what's happen. A class is identified by its name and its
ClassLoader. Jigsaw has a specific ClassLoader that can reload modified
classes. So, in that case, The class loaded by the getServlet method is
not the same than the class loaded by the system.

So, you just have to set the "auto-reload" flag of ServletWrapper to false
and to put your servlet classes in the CLASSPATH. In that configuration
the special ClassLoader is desactivated.

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, 3 June 1998 20:56:39 UTC