I've spent the last 3 days trying to get tomcat to run php as a servlet with no success. I have never used either before, so I'm not sure where my mistake lies.
Here's what I've done. I've tried to follow the instructions from sapi/servlet/README
0. I have a working Sun jdk 1.3.1_04 on my RedHat 7.3 workstation.
1. Install tomcat 3.3.1 from source according to the instructions. Tomcat can serve its example pages fine.
2. Configured PHP 4.2.3 like this: ./configure --with-pgsql --with-java --without-mysql --with-servlet Then I compile with "make". I also did "make install" as root.
3. Added the dir containing libphp4.so ot my LD_LIBRARY_PATH. For good measure I also ran "ldconfig -v" and saw that libphp4.s0 was being picked up.
4. Add phpsrvlt.jar to CLASSPATH, even though it looks like tomcat ignores the classpath. So I also put it in the tomcat lib/common directory.
5. Merged the sap/servlet/web.xml file in with build/tomcat/examples/WEB-INF/web.xml from tomcat.
6. Created the test.php file with only "<?php phpinfo(); ?>" in it in a variety of places in the Tomcat filespace.
When I screwed up step 5 and edited the wrong web.xml file, then looked at test.php with my browser, I just got "<?php phpinfo(); ?>". Now that I have a better web.xml file I get java.lang.NoClassDefFoundError:
javax/servlet/http/HttpServlet
(I've appended the full message below). Clearly it is now trying to do something with the file.
I'm clearly missing somthing--probably something simple--but I can't figure out what.
any help/suggestions/ideas would be welcome.
Thanks,
Michael
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:106)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:243)
at java.net.URLClassLoader.access$100(URLClassLoader.java:51)
at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:287)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:548)
at java.lang.ClassLoader.loadClass(ClassLoader.java:287)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:548)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependClassLoader.java:174)
at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader12.java:92)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoader12.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at org.apache.tomcat.facade.ServletHandler.getServlet(ServletHandler.java:343)
at org.apache.tomcat.facade.ServletHandler.preInit(ServletHandler.java:439)
at org.apache.tomcat.facade.ServletHandler.init(ServletHandler.java:228)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:472)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:479)