MODIFICATIONS NEEDED TO TOMCAT JAVA_OPTS -Djava.library.path=$PHP_INST_DIR/lib export LD_LIBRARY_PAT$PHP_INST_DIR/lib/dummylib export PHPRC=$PHP_INST_DIR/lib N.b. This modification makes .php files work for all webapps! No webapp web.xml file needed. Could not find script.jar until I copied it from $CATALINA_HOME/shared/lib to $CATALINA_HOME/common/lib. I changed the modification of Tomcat's startup.sh to source $CATALINA_BASE/env.sh if it's readable and moved *jsr*.sh to there. Apply changes in my HTML file to $CATALINA_BASE/conf/web.xml. Restore original server.xml and just add a $CATALNA_BASE/conf/Catalina/localhost/jsr223samples.xml: I attempted to use SuSE's PHP 5 instead of the one supplied with the old JSR package, but that didn't work. It probably didn't work because the only SuSE libphp5.so is from the Apache PHP module. I think that if I built libphp5.so from the PHP5 source RPM, it might work. All that is needed from the distro is: dummylib/libns-httpd40.so phplib/libphp5.so phplib/php.ini # SEEMS THAT IT IS NOT USED! Use env.sh file that does: export JAVA_OPTS=-Djava.library.path=/path/to/directory/containing/libphp5.so/ # Add to LD_LIBRARY_PATH... if [ "$LD_LIBRARY_PATH" = "" ] ; then LD_LIBRARY_PATH=/path/to/directory/containing/libns-httpd40.so/ else LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/directory/containing/libns-httpd40.so/ fi export LD_LIBRARY_PATH PHPRC=/path/to/directory/containing/php.ini/ export PHPRC ##### CODING *** N.b. PHP method names are case insensitive. Construct objects: new Java("package.Class"); // MUST specify abs. package even in java.lang new Java("package.Class", 0th arg, 1st arg); Class objects: $c = new JavaClass("package.Class"); or PHPClass::$c = new JavaClass("package.Class"); self::$c = new JavaClass("package.Class"); The returned static class is a PHP variable instance which is determined by the PHP variable. PHP $date.time first looks for Java $date.getTime(), then $date.time. (http://us3.php.net/java) Can't use anonymous object constructors like (new Java("X"))->method(); #### TRIAL AND ERROR I think that httpd-built PHP sets $PWD to the directory a page is being retrieved from. jsr223 keeps Tomcat's $PWD. Try setting include_path in the php.ini file. Can't get php.ini to work!!! WORKAROUND: In every page, put $system = new JavaClass("java.lang.System"); chdir( $system->getProperty("catalina.base") . "/webapps" . dirname(__FILE__)); No no. This won't do either. Race condition. Need to put the getProperty right into each include and similar. Looks like the php.ini file isn't used at all???????? Global vars are not shared among different pages. I can't figure if or where php.ini is used from!!! For log4j logging formats, use "c" to identify the caller, not "C". Seems that PHP runs "as a server module version of PHP", since php.ini is loaded only once when the server is startet. (I.e., not CGI or CLI). This is true even across web apps and web app restarts. ############################################# REBUILDING MY OWN JSR223 Install the php5 source rpm. I make a directory like this /tmp/php5/distros # Copy everything from the source rpm to here # "rpm -i" puts them into /usr/src/packages/SOURCES # regardelss of --prefix. Go up one and extract the main tar file. Forget the *suse-addons* tar, which is for Apache integration. Go into distros and remove all *.patch files which head shows are for an older version of php, or which patch non-existent files (like RPC*). List patch files in the distro directory in time order. Going from oldest to newest, run "patch -p0 .../distros/file.patch" for each .patch file. Before running "patch", you need to head each .patch file to see what directory you need to be in. It will be either /tmp/php5 (parent of php-*) or /tmp/php5/php-* itself. Run ./configure --prefix=/tmp/php5/php-5.0.4/work --with-java=/usr/lib/jvm/jre-1.4.2-sun/bin/java --enable-servlet --disable-xml --disable-dom --disable-simplexml --disable-libxml --without-pear CFLAGS= # This won't make the shared lib. Save output of "make libs/libphp5.bundle" to a script, and modify the switches like so: gcc... -shared -Wl,-soname,libphp5.so,-export-dynamic -lcrypt -lcrypt -lresolv -lm -lnsl -lcrypt -lcrypt -o libs/libphp5.so -lc Lastly, I tried gcc... -lcrypt -lcrypt -lresolv -shared -Wl,-soname,libphp5.so,-export-dynamic -nostartfiles -lm -lnsl -lgcc -lcrypt -lcrypt -o libs/libphp5.so Note that we want a shared lib (.so, not static .a), but not a DLL shared lib. Therefore, I added --with-pic to ./configure run, and modified Makefile: From CFLAGS_CLEAN = -g -O2 To CFLAGS_CLEAN = -g -O2 -fPIC -nostartfiles NO MATTER WHAT I DO. The Java line "System.loadLibrary("php5");" in PHPBridge.java (from script.jar) generates error: java.lang.UnsatisfiedLinkError: init at com.sun.script.php.PHPBridge.init(Native Method) It is finding the library (or the message would say that it can't). "file" also shows that it is a non-dynamic shared lib, same as JSR-supplied lib. I think the root problem is that I don't have the native .c or .o used by the JNI classes in script.jar. These reside in the supplies libphp.so, but I'm unable to extract them or use "just" them from this file. Seems that the JSR build of php does not set $_SERVER["HTTP_HOST"] according to the HTTP request??? Workaround: Use $_SERVER["SERVER_NAME"] instead. N.b.!!!!! Disable the servlet mapping for *.js. Browsers need to download client-side javascript files! When get reals (DECIMAL(x,y)) from MySql, getObject() gets a strange "java" "object" which dumps as if it were empty, yet it prints in a string like a float. The JRS-supplied sample that uses $request->getSession()... does not work. Just use the normal PHP $_SESSION to use the Session.