Hello Sebastian, See intermixed stuff below.
On Sat, 27 Oct 2001, Sebastian Bergmann wrote: > Date: Sat, 27 Oct 2001 10:01:30 +0200 > From: Sebastian Bergmann <[EMAIL PROTECTED]> > Reply-To: Tomcat Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: Tomcat User Mailinglist <[EMAIL PROTECTED]> > Subject: Integrating PHP 4 with Tomcat > > Hello there! > > I'm new to this list, so I'll introduce myself quickly: As one can > already guess from this mail's From: header - my name is Sebastian > Bergmann. I am a 23 years old computer science student from Germany and > involved in various Open Source projects, most actively with PHP and > phpOpenTracker. > > This semester I'm attending a cource at my university that focuses on > Apache's Tomcat and Cocoon2 projects. Although I like Java as a > programming language, I never used it in 'real world' applications, but > only for University projects. > > Beeing 'confronted' with the concepts of Tomcat and Cocoon2 I > remembered Sam Ruby's Java Servlet SAPI [1] implementation for PHP 4. > This SAPI modules enables the execution of the PHP processor as a > Servlet. > > Having already installed Tomcat 4.0 and Cocoon 2.0 RC1 on my Win2K box > I decided to install the PHP 4 servlet SAPI module first [2] in such a > way, that Tomcat would be able to execute .php scripts. > > Sam Ruby writes in the Java Servlet SAPI readme: > > "add phpsrvlt.jar to CLASSPATH > add directory containing php4ts.dll and phpsrvlt.dll to PATH > merge/overwrite build\tomcat\examples\WEB-INF\web.xml from > sapi\servlet" > > Given the fact that Sam Ruby wrote this over a year ago and for Tomcat > 3.x, some things must have changed. > This one is pretty easy. Just put "phpsrvlt.jar" in the $CATALINA_HOME/lib directory, and it will be made available automatically. Alternatively, you can put it in the /WEB-INF/lib directory of your web application itself. > One thing I found out is that CLASSPATH is beeing overwritten by > catalina.bat, which caused the phpsrvlt.jar not be found. I solved > this problem by changing line 75 of catalina.bat to > > set CLASSPATH=%CP%;%_CLASSPATH% > > Another problem I came across is a parse error in the web.xml, that > comes with the Java Servlet SAPI: > > <web-app> > <servlet> > <servlet-name> > php > </servlet-name> > <servlet-class> > net.php.servlet > </servlet-class> > </servlet> > <servlet-mapping> > <servlet-name> > php > </servlet-name> > <url-pattern> > *.php > </url-pattern> > </servlet-mapping> > <servlet> > <servlet-name> > php-formatter > </servlet-name> > <servlet-class> > net.php.formatter > </servlet-class> > </servlet> > <servlet-mapping> > <servlet-name> > php-formatter > </servlet-name> > <url-pattern> > *.phps > </url-pattern> > </servlet-mapping> > </web-app> > > Tomcat accepts this configuration, if I remove everything except the > first <servlet> and <servlet-mapping> section. The second ones are only > needed to pretty-print a PHP script's source, so this is not dramatic. > The problem under Tomcat 4 is that the element ordering is not legal, so the XML parser that reads web.xml rejects it. To fix this, put all the <servlet> declarations first, followed by all the <servlet-mapping> declarations. > Having done all this, I put a simple test.php > > <?php phpinfo(); ?> > > into Tomcat/webapps/php, together with the web.xml in this directory's > WEB-INF directory. > > When I access http://localhost:8080/php/test.php, I get this error > message: > > A Servlet Exception Has Occurred > Exception Report: > javax.servlet.ServletException: Class net.php.servlet is not a Servlet > at org.apache.catalina.core.StandardWrapper.load > at org.apache.catalina.core.StandardWrapper.allocate > at org.apache.catalina.core.StandardWrapperValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.core.StandardContextValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.core.StandardContext.invoke > at org.apache.catalina.core.StandardHostValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.valves.AccessLogValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.core.StandardEngineValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.connector.http.HttpProcessor.process > at org.apache.catalina.connector.http.HttpProcessor.run > at java.lang.Thread.run(Thread.java:484) > > Root Cause: > java.lang.ClassCastException: net.php.servlet > at org.apache.catalina.core.StandardWrapper.load > at org.apache.catalina.core.StandardWrapper.allocate > at org.apache.catalina.core.StandardWrapperValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.core.StandardContextValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.core.StandardContext.invoke > at org.apache.catalina.core.StandardHostValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.valves.AccessLogValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.core.StandardEngineValve.invoke > at org.apache.catalina.core.StandardPipeline.invokeNext > at org.apache.catalina.core.StandardPipeline.invoke > at org.apache.catalina.core.ContainerBase.invoke > at org.apache.catalina.connector.http.HttpProcessor.process > at org.apache.catalina.connector.http.HttpProcessor.run > at java.lang.Thread.run(Thread.java:484) > > Any ideas on what I could be doing wrong here, or what could be amiss > with PHP's Java Servlet SAPI, since it's code hasn't changed since > its original submission by Sam Ruby last year? > The most likely explanation is that you have a servlet.jar in your $JAVA_HOME/jre/lib/ext directory. This interferes with the servlet.jar file that is included with Tomcat, and causes "xxxxx is not a Servlet" type error messages. > Greetings, > Sebastian > Craig McClanahan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>