- From: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>
- Date: Tue, 02 Jun 1998 09:05:56 +0200
- To: "S.Ramaswamy" <srswamy@giasdl01.vsnl.net.in>
- cc: www-jigsaw@w3.org
"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 Tuesday, 2 June 1998 03:05:40 UTC