php --with-servlet, mod_jserv, tomcat problems
| From: | greg keraunen | Date: | Thu, 21 Sep 2000 22:56:51 +0000 |
| Subject: | php --with-servlet, mod_jserv, tomcat problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-17265@lists.php.net to get a copy of this message | ||
I have been working for the last week or so to get php running as a
servlet with tomcat. It has been a struggle and not much documentation
or discussion on this list yet so I will try to outline only the current
problem I'm having and leave out the many other problems that I have
resolved to get to this point.
First, below is the error message that tomcat is generating, (this
message is also being logged by tomcat so I know it is coming from
tomcat's JVM and not from another JVM, such as you would get running php
--with-java and without tomcat). I hope someone can offer some
assistance.
Error: 500
Location: /valence/valence.php
Internal Servlet Error:
java.lang.UnsatisfiedLinkError: send
at net.php.servlet.service(servlet.java, Compiled Code)
at net.php.servlet.service(servlet.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java,
Compiled Code)
at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java,
Compiled Code)
at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java,
Compiled Code)
at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
Compiled Code)
at java.lang.Thread.run(Thread.java, Compiled Code)
Here's my config:
OS: linux: valinux RH 6.2
PHP: 4.0.2
./configure --with-servlet --with-mysql=/usr/local/mysql --with-java
--with-apxs --enable-track-vars
and (see below):
./configure --with-mysql=/usr/local/mysql --with-java --with-apxs
--enable-track-vars
apache: 1.3.12
jakarta-tomcat: 3.10
java: jdk1.2.2
Loaded apache Modules:
mod_jserv, mod_php4, mod_setenvif, mod_so, mod_auth, mod_access,
mod_alias, mod_userdir,
mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex,
mod_include, mod_status,
mod_negotiation, mod_mime, mod_log_config, mod_env, http_core
I have posted previously to the php-install list details on my inability
of apache
to LoadModule libphp4.so when php was compiled --with-servlet since
apache gives the error:
> "Can't locate API module structure `php4_module' in file
> /usr/local/lib/libphp4.so"
In order to get apache to load php module, I had to compile with every
option except --with-servlet and that is the module I am loading now. Is
it possible that this is the cause of my trouble since I am running php
as a servlet but without a libphp4.so compiled --with-servlet???
Let me back up and discuss some issues that were not covered at all in
php4/sapi/servlet/README:
* I went through a bunch of hassles to get tomcat installed and testing
good.
* I created a tomcat context for my application in
tomcat/conf/server.xml
* I copied my application, htdocs/valence/php directory to
tomcat/webapps/valence
* I edited tomcat/conf/server.xml to increase logging for valence
context to 9
* I have edited my apache/conf/httpd.conf file as follows. Is this
correct for running php as servlet?
LoadModule php4_module /usr/local/lib/libphp4.so
AddHandler jserv-servlet .php
AddType application/x-httpd-php .php .php3
I discovered that if I did not LoadModule php4_module that tomcat cannot
handle .php all alone: it seems to assume that the php file must be jsp
code and gives a corresponding error message.
I also tried adding the application/x-http-php mime type mapping to the
tomcat/conf/web.xml file but this doesn't seem to have any effect.
<mime-mapping>
<extension>
php
</extension>
<mime-type>
application/x-httpd-php
</mime-type>
</mime-mapping>
I also discovered that if I did not use the AddHandler jserv-servlet
.php that tomcat would not be called into action at all.
This is something that many people might not realize: php java stuff
will work fine as long as you have compiled --with-java.
So how do you tell if tomcat is really working??? Don't just assume that
if php & java is working that tomcat is working!
One thing I don't understand about tomcat:
I don't see anywhere that mime types are associated with servlets in
<servlet> tag.
Can anyone explain the basics of how apache/php/tomcat work together
with php running --with-servlet and --with-java?
This is what I think is happening, going on mere intuition:
1. Apache receives http request and looks at file extension .php
2. Apache sees .php is mapped to application/x-httpd-php mime-type
3. Apache knows that AddHandler .php means it should hand off the
request to 'jserv-servlet'
QUESTION: how does apache know that 'jserv-servlet' means to use
mod_jserv.o?
4. mod_jserv.o receives the request from apache, along with the
mime-type (?)
5. mod_jserv.o (or apache?) knows to use libphp4.so to parse the .php
file
QUESTION: how does apache know that application/x-httpd-php should be
handled by 'php4_module'? does libphp4.so export 'php4_module' as an ID
in the apache environment?
6. Somebody (libphp4.so, apache. mod_jserv.o???) is using libphp4.so for
parsing php file...
when <?php new java(); ?> is encountered, somehow somebody knows to
hand this off to tomcat
QUESTION: or is the parsing of php code already in tomcat process space
at this point? Is tomcat using libphp4.so directly?
QUESTION: Is this the point where my java.lang.UnsatisfiedLinkError:
send is coming from?
7. If things worked correctly, at this point tomcat should exectute the
java code and return results to libphp4.so
8. libphp4.so returns data to apache and out goes the http response.
Now one thing I am thinking is that maybe if I could configure tomcat so
that tomcat would generate my AddType php mime-mapping and the
AddHandler inside the auto-generated apache-tomcat.conf file maybe this
would help since I would be sure that tomcat internally knows about how
to handle php correctly.
tomcat-apache.conf includes:
AddType test/jsp .jsp
I don't know how it is doing this - I can't find this string anywhere
inside tomcat except in path references; don't know where it is getting
created from.
Can I find some way to get tomcat-apache.conf to automatically include
the AddHandler line for php? Does it matter?
As it is now, I have manually added the php AddType and AddHandler in
my main httpd.conf, as usual.
Another thing that is not clear in the tomcat users guide is this:
from:
http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/tomcat-ug.html#configuring_tomcat
>In Tomcat's case, there are three different modes of execution Tomcat supports.
1.Stand-alone servlet containers
These are an integral part of the web server. This is the case
when using a Java-based web server, for example the servlet container
that is part of the
JavaWebServer. Stand-alone is the default mode used by Tomcat.
Most web servers, however, are not Java-based, which leads us to the
next two
container types.
2.In-process servlet containers
The servlet container is a combination of a web server plugin and
a Java container implementation. The web server plugin opens a JVM
inside the web
server's address space and lets the servlet container run in it.
If a certain request should execute a servlet, the plugin takes control
over the request and
passes it (using JNI) to the servlet container. An in-process
container is suitable for multi-threaded single-process servers and
provides good performance
but is limited in scalability.
3.Out-of-process servlet containers
The servlet container is a combination of a web server plugin and
a Java container implementation that runs in a JVM outside the web
server. The web
server plugin and the Java container JVM communicate using some
IPC mechanism (usually TCP/IP sockets). If a certain request should
execute a servlet
the plugin takes control over the request and passes it (using
IPC) to the servlet container. The response time of an out-of-process
engine is not as good as
in the in-process one but the out-of-process engine performs
better in many measurable ways (scalability, stability, etc.).
In what mode will tomcat run with php4/sapi/servlet?
I am assuming it is case 2 above where mod_jserv is the 'server plugin'.
Is that correct? And I think tomcat is the 'servlet container'.
(wouldn't it be nice if people who wrote user's guides defined their
terms more often? :-)
I have tried watching tcp/ip packets with tcpdump on port 8007 and 8080,
where tomcat is supposedly listening, but don't see any action, not even
when apache is serving .jsp pages through mod_jserv, so I guess that
proves that tomcat is running as a plug-in.
In this case, I think the only way to know if tomcat, rather than
php/apache is actually working with your application is to turn up
tomcat logging and look at the logs.
The tomcat tomcat/conf/tomcat.properties says that thread pool is not
stable enough for production and config file has it turned off, by
default. I have not tried turning it on yet and won't until I get the
basic php servlet running.
Thanks for any insights!
--
greg keraunen <gkeraunen@valinux.com> 408-542-8600 x8085
web software engineer