You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Sebastian Bergmann <li...@sebastian-bergmann.de> on 2001/10/27 17:55:24 UTC

Integrating PHP 4 with Tomcat

  (I already tried twice today to send this posting to tomcat-user@, but
  it did not went through, as of yet. As I think it more likely to get an
  answer to my problem on this list, I sent it here now. Sorry if I'm out
  of the line or off-topic here.)

  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.

  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.

  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?

  Greetings,
Sebastian

  [1] SAPI is PHP 4's server abstraction layer.

  [2] The next step beeing to use PHP as a generator with Cocoon2.

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Integrating PHP 4 with Tomcat

Posted by Pier Fumagalli <pi...@betaversion.org>.
Sebastian Bergmann at lists@sebastian-bergmann.de wrote:

> Pier Fumagalli wrote:
>> There have been some problems with the mailing list server, and we're
>> splitting servers ATM... At least for the tomcat mailing lists, ATM,
>> everything should be now just fine (more or less)...
> 
> Ah, okay, I see. Sorry then for sending my posting three times :-/

No problems... I tried to catch most of them in my moderator queue, but some
might just have slipped... :)

    Pier (BTW, the queue on daedalus is gone, we're back to normal)



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Integrating PHP 4 with Tomcat

Posted by Sebastian Bergmann <li...@sebastian-bergmann.de>.
Pier Fumagalli wrote:
> There have been some problems with the mailing list server, and we're
> splitting servers ATM... At least for the tomcat mailing lists, ATM,
> everything should be now just fine (more or less)...

  Ah, okay, I see. Sorry then for sending my posting three times :-/

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Integrating PHP 4 with Tomcat

Posted by Pier Fumagalli <pi...@betaversion.org>.
Sebastian Bergmann at lists@sebastian-bergmann.de wrote:

> (I already tried twice today to send this posting to tomcat-user@, but
> it did not went through, as of yet. As I think it more likely to get an
> answer to my problem on this list, I sent it here now. Sorry if I'm out
> of the line or off-topic here.)

There have been some problems with the mailing list server, and we're
splitting servers ATM... At least for the tomcat mailing lists, ATM,
everything should be now just fine (more or less)...

Old messages are still in the backlog, and will pop up in the next 12 hours,
right now all I need to do is remove load from the main queue :)

    Pier


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>