-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have tried without success for several days to get the PHP servlet
running under Tomcat. My environment is as follows:

Suse Linux 9.3
[EMAIL PROTECTED]:~/tomcat/apache-tomcat-5.5.15/logs> uname -a
Linux aragorn 2.6.11.4-21.10-default #1 Tue Nov 29 14:32:49 UTC 2005
i686 i686 i386 GNU/Linux

[EMAIL PROTECTED]:~/tomcat/apache-tomcat-5.5.15/logs> java -version
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

Tomcat 5.5.15 installed under my home directory to avoid any
permissions problems.

[EMAIL PROTECTED]:~/tomcat/apache-tomcat-5.5.15/common/lib> php -i
phpinfo()
PHP Version => 4.4.2

System => Linux aragorn 2.6.11.4-21.10-default #1 Tue Nov 29 14:32:49
UTC 2005 i686
Build Date => Mar 25 2006 12:09:10
Configure Command =>  './configure' '--prefix=/usr/local'
'--with-java=/usr/local/java/jdk1.5.0_04/'
'--with-servlet=/usr/local/java/apache-tomcat-5.5.15/common'
'--datadir=/usr/local/share/php' '--mandir=/usr/local/man'
'--bindir=/usr/local/bin' '--libdir=/usr/local/share'
'--includedir=/usr/local/include' '--sysconfdir=/etc'
'--with-_lib=lib' '--with-config-file-path=/etc'
'--with-exec-dir=/usr/local/lib/php/bin' '--disable-debug'
'--enable-inline-optimization' '--enable-memory-limit'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sigchild'
'--disable-ctype' '--disable-session' '--without-mysql'
'--disable-cli' '--without-pear' '--with-openssl'
'--enable-force-cgi-redirect' '--enable-discard-path' '--enable-cli'
'--with-pear' 'i586-suse-linux'
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => /etc
PHP API => 20020918
PHP Extension => 20020429
Zend Extension => 20050606
Debug Build => no
Zend Memory Manager => enabled
Thread Safety => enabled
Registered PHP Streams => php, http, ftp, https, ftps


This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

... I can provide the rest of the PHP config info, if requested.

I configured and built the Tomcat native library used by the Apache
Portable Runtime (APR) on this system during this time period using
openssl-0.9.7i and apr-1.2.2 and copied all of the newly built
libraries and links from the .libs directory to <tomcat home>/common/lib

I altered the enum variables in the servlet.java class from enum to
xenum to avoid the keyword clash that occurs in using JDK 1.5. I also
altered the PHP configure file to use servlet-api.jar instead of
servlet.jar, since JDK 1.5 is being used. Both of these alterations
are also suggested at: http://wiki.apache.org/tomcat/UsingPhp

I configured and built PHP as shown above in the configure command. I
reviewed the output from the compilation of the reflect.java and
servlet.java classes and saw no errors. I copied the newly built
phpsrvlt.jar and libphp4.so files to <tomcat home>/common/lib

The following complaint about the PERL Compatible Regex  did show
during configure, but I don't think it is related to my current problem.
...
checking for Java support... yes
checking Java Jar location... /usr/local/java/jdk1.5.0_04//bin/jar cf
checking Java C location... /usr/local/java/jdk1.5.0_04//bin/javac
checking Checking for libjava... /usr/local/java/jdk1.5.0_04//jre/lib/i386
sed: can't read /home/gsl/downloads/php-4.4.2/ext/pcre/Makefile.frag:
No such file or directory
checking for LDAP support... no
...

The Makefile.frag file is indeed missing as sed states.

I placed the servlet config as described in the wiki above into
<tomcat home>/conf/web.xml by copying it from the web.xml file located
in the PHP source distribution at <PHP source root
directory>/sapi/servlet/web.xml.

I also altered the <tomcat home/conf/server.xml file as follows:

    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080

         Added protocol attribute. gsl 22Mar2006.
    -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true"
               protocol="org.apache.coyote.http11.Http11AprProtocol" />

to allow access the APR protocol.

I placed the file test.php in directory <tomcat home>/webapps whose
contents is:
[EMAIL PROTECTED]:~/tomcat/apache-tomcat-5.5.15/webapps> cat test.php
<?php phpinfo(); ?>

I added the following to catalina.sh (could have done this with an env
export as well):
CATALINA_OPTS="$CATALINA_OPTS
- -Djava.library.path=/home/gsl/tomcat/apache-tomcat-5.5.15/common/lib"

I then started up Tomcat using ./startup.sh under the bin directory
and confirmed that Tomcat was running "correctly" by accessing
http://localhost:8080 at which point I saw the familiar Tomcat page.

I then attempted to go to the page http://localhost:8080/test.php at
which point I received:
*
description* _The server encountered an internal error () that
prevented it from fulfilling this request._

*exception*

java.io.IOException: null
    net.php.servlet.send(Native Method)
    net.php.servlet.service(servlet.java:207)
    net.php.servlet.service(servlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


I then altered the servlet class to include some debugging info just
prior to its invocation of the send method:

  send(request.getMethod(),
          request.getQueryString(),
          request.getRequestURI(),
          contextPath,
          request.getContentType(),
          request.getContentLength(),
          request.getRemoteUser(),
          display_source_mode
         );

Here is the result:
request.getMethod()               = GET
request.getQueryString()        = null     
request.getRequestURI()        = /test.php
contextPath                             =
/home/gsl/tomcat/apache-tomcat-5.5.15/webapps/ROOT/test.php
request.getContentType()       = null
request.getContentLength()    = -1
request.getRemoteUser()        = null
display_source_mode             = false

The corresponding native method appears to be in servlet.c as:

JNIEXPORT void JNICALL Java_net_php_servlet_send
        (JNIEnv *jenv, jobject self,
         jstring requestMethod, jstring queryString,
         jstring requestURI, jstring pathTranslated,
         jstring contentType, jint contentLength,
         jstring authUser, jboolean display_source_mode)

I haven't written JNI code before, but I suspect that the first two
args are just hidden info. that is typically passed to a native
method, so I don't see a signature mismatch or anything else wrong here.

I have also done the following:

Removed the libtcnative libs and confirmed that tomcat complains and
replaced them and confirmed that it no longer complains.

Removed the libphp4.so lib and confirmed that tomcat complains and
replaced it and confirmed that it no longer complains.

Confirmed that the servlet is being called, since the debug messages I
put into it are being logged to a file with the info shown above.

Does anyone see a misconfiguration problem with what I have done?

Alternatively, does anyone have any further ideas on what I could do
to debug this further?

A few other individuals posted this null IOException on the net, but
no resolution was provided. Being such a generic error, their problem
might not even be related to what I am experiencing.

Any help would be greatly appreciated.

                              -=> Gregg <=-

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEJ0YpMcSsEtbyA2cRAhXOAKCEikAca/zkE4xgrqzFgRKPQPhPAQCfdsDr
AzA0OvUvTRVRT8250zLyXFo=
=tXMz
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to