DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3896>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3896 ClassCastException when invoking certain subclasses of HTTPServlet Summary: ClassCastException when invoking certain subclasses of HTTPServlet Product: Tomcat 4 Version: 4.0 Final Platform: Sun OS/Version: Solaris Status: NEW Severity: Normal Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] When invoking a servlet that is a subclass of org.webmacro.http.WMServlet (which in turn is a direct subclass of HTTPServlet) the Catalina core throws a ServletException that is a linked to a ClassCastException: Here is a snippet from the log file 2001-10-01 12:19:59 StandardWrapper[:org.apache.catalina.INVOKER.hermes.web.HelloWorld]: Marking servlet org.apache.ca talina.INVOKER.hermes.web.HelloWorld as unavailable 2001-10-01 12:19:59 invoker: Cannot allocate servlet instance for path /servlet/hermes.web.HelloWorld javax.servlet.ServletException: Class hermes.web.HelloWorld is not a Servlet at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:848) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:621) at org.apache.catalina.servlets.InvokerServlet.serveRequest(Unknown Source) at org.apache.catalina.servlets.InvokerServlet.doGet(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source) at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source) at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source) at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source) at org.apache.catalina.core.ContainerBase.invoke(Unknown Source) at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source) The problem seems to occur in the following lines in org.apache.catalina.core.StandardWrapper: try { servlet = (Servlet) classClass.newInstance(); } catch (ClassCastException e) { unavailable(null); // Restore the context ClassLoader throw new ServletException (sm.getString("standardWrapper.notServlet", actualClass), e); } By splitting the line servlet = (Servlet) classClass.newInstance(); and adding some debugging output log("Trying to instantiate " + classClass.getName()); Object instance = classClass.newInstance(); log("Instantiated, instance is " + instance); log("Trying to cast ..."); servlet = (Servlet) instance; one can focus that instance (which is of class hermes.web.HelloWorld) cannot be casted to Servlet. The class hierarchy is as follows Interface javax.servlet.Servlet ^ | implements | Class javax.servlet.GenericServlet ^ | extends | Class javax.servlet.http.HttpServlet ^ | extends | Class org.webmacro.servlet.WMServlet ^ | extends | Class hermes.web.HelloWorld Clearly, HelloWorld should be castable to Servlet. I have no idea why the cast fails. May be something is wrong with the class loader. Daniel Faensen