You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Randy Layman <ra...@aswethink.com> on 2001/08/29 17:44:25 UTC

RE: Why does servlet.jar break servlets?

	Any class in common/lib (on TC 3.3, lib in TC 3.2) does not, and
really can not be in the WEB-INF/lib.  The reason is that two different
class loaders load the classes, which makes them not equal and not castable,
thus the reason for the Class Cast Exceptions - your WEB-INF classes don't
extend the HttpServlet in common/lib, it  extends the HttpServlet in
WEB-INF/lib.

	Randy

> -----Original Message-----
> From: Eryq [mailto:eryq@zeegee.com]
> Sent: Wednesday, August 29, 2001 12:00 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Why does servlet.jar break servlets?
> 
> 
> I've noticed something which seems quite odd.
> 
> It appears that I need the javax.servlet.* classes in
> order to compile my servlet, to get classes such as
> javax.servlet.http.HttpServletRequest, etc.
> 
> The classes can be found in a servlet.jar included
> with TDK-2.1, in common/lib.
> 
> However, it appears that servlet.jar does not need
> to be in the WEB-INF/lib directory of a servlet
> in order for the servlet to run.
> 
> Furthermore. I have noticed that if I put servlet.jar 
> in the WEB-INF/lib directory of a Tomcat4-b7 servlet
> (including the "examples" servlets), it breaks them...
> horribly.  I get ClassCastExceptions or worse.
> 
> I am guessing that javax.servlet is somehow
> "special", and that it's the servlet container's
> job to ensure that the servlet has access to it,
> no matter what might be in the WEB-INF/lib directory.
> 
> I am also guessing that there might be a Servlet API 2.2
> versus 2.3 issue going on.
> 
> Anyway, if anyone can shed more light on this,
> I'd be very interested in understanding it a bit more.
> 
> Thanks,
> 
> Eryq
>