tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: servlet mapping under tomcat4
Date Sun, 18 Mar 2001 23:06:51 GMT


On Sun, 18 Mar 2001 cgokey@gcmd.gsfc.nasa.gov wrote:

> Hi everyone,
> 
> I'm having trouble getting servlet mapping to work under Tomcat
> 4.0-1-b1. 
> 
> In previous version of Tomcat, it was enough to just put your servlet
> mapping class in the "classes" directory under $TOMCAT_HOME and add this
> to your web.xml file:
> 
>  <servlet-mapping>
>        <servlet-name>
>            PyServlet
>        </servlet-name>
>        <url-pattern>
>            *.py
>        </url-pattern>
>   </servlet-mapping>
> 
> and everything worked!  If I do this with Tomcat 4.0-1-b1, I get this
> error when starting Tomcat.
> ------------------------------------------
> Using CATALINA_HOME: /home/mddevel/MD8/packages/jakarta-tomcat-4.0-b1/
> Starting service Tomcat-Standalone
> Apache Tomcat/4.0-b1
> ERROR reading java.io.FileInputStream@11c97e2
> At Line 68 /web-app/servlet-mapping/ 
> 
> ERROR reading java.io.FileInputStream@1b52828
> At Line 68 /web-app/servlet-mapping/ 
> 
> ERROR reading java.io.FileInputStream@1fb6e39
> At Line 68 /web-app/servlet-mapping/ 
> 
> ERROR reading java.io.FileInputStream@5e10f8
> At Line 68 /web-app/servlet-mapping/ 
> 
> ERROR reading java.io.FileInputStream@1ceb934
> At Line 68 /web-app/servlet-mapping/ 
> 

Which line is line 68?

> Starting service Tomcat-Apache
> ----------------------------------------
> So, I tried looking at the structure of the other servlet mapping files
> in web.xml and noticed that I might need to do this:
>  <servlet>
>     <servlet-name>PyServlet</servlet-name>
>     <servlet-class>md8.util.PyServlet</servlet-class>
>   </servlet>
> 

Yes, you will need this entry to use a servlet mapping, and it must appear
*before* the <servlet-mapping> entry in order to satisfy the DTD
requirements.

> Everything seems to work when I startup Tomcat, but when I run a .py
> file (which should map it to PyServlet), it produces this error:
> 
> -----------------------------------------
> A Servlet Exception Has Occurred
> 
> Exception Report:
> 
> javax.servlet.ServletException: Class md8.util.PyServlet is not a Servlet

Well, at least it is recognizing the mapping correctly :-)

>         at java.lang.Throwable.fillInStackTrace(Native Method)
>         at java.lang.Throwable.fillInStackTrace(Compiled Code)
>         at java.lang.Throwable.(Compiled Code)
>         at java.lang.Exception.(Compiled Code)
>         		.
>         		.
>         		.
> Root Cause:
> 
> java.lang.ClassCastException: md8.util.PyServlet
>         at org.apache.catalina.core.StandardWrapper.load(Compiled Code)
>         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:544)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:227)
>         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
> 			.
> 			.
> 			.

There were some older nightly builds of Tomcat 4.0 that exhibited this
problem due to bugs in Tomcat, but they were cleaned up by beta 1.  What
version are you trying?

> ----------------------------------------------
> Can someone shed some light what might be happing? This class IS a
> servlet:
> 
> public class PyServlet extends HttpServlet {
>     static Hashtable servlets = new Hashtable(); // Cache for PyServlets
>     static Hashtable dates = new Hashtable();   // Timestamps for Cache entries
>     PythonInterpreter interp = new PythonInterpreter(); 
> 			.
> 			.
> 			.
> 
> Again, this used to work under the previous version of Tomcat just fine
> and it was considered to be a servlet.  
> 

The only other possibility I can think of is if you have a copy of
"servlet.jar" in your system extensions directory
($JAVA_HOME/jre/lib/ext).  If so, this will interfere in nasty ways with
the class loaders in Tomcat 4.0, because Tomcat expects to use the
"servlet.jar" file that is in $TOMCAT_HOME/common/lib (in current nightly
builds).

> Thanks,
> Chris
> 

Craig McClanahan


Mime
View raw message