Click to See Complete Forum and Search --> : PLEASE HELP!! php/java hell
putremos
06-13-2001, 09:39 AM
Hope someone can put me out of my misery, i've been trying to get PHP 4.0.5 --with-java=/usr/java/jdk1.3.1 for about 3 weeks now on a Cobalt RaQ3i, mostly trying out different settings in php.ini and environment variables. phpinfo shows me lots of good stuff and I'm sure PHP is working fine apart from Java support. Todays error message of the day is:
Fatal error: Unable to load Java Library /usr/java/jdk1.3.1/jre/lib/i386/libjava.so, error: /usr/java/jdk/jre/lib/i386/classic/libjvm.so: undefined symbol: jdk_sem_post in /home/pm/jver.php on line 4
I've added several lines to my .profile script specifying CLASSPATH, PATH and LD_LIBRARY_PATH making sure they match the corresponding lines in the php.ini and never and joy.
I'm beginning to think I have some fundemental problems with the JDK/Java setup on my machine:
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Classic VM (build 1.3.1-b24, green threads, nojit)
Might be worrying that ld libjava.so gives me the following result:
ld: warning: cannot find entry symbol _start; not setting start address
libjava.so: undefined reference to `jdk_sem_post'
libjava.so: undefined reference to `jdk_waitpid'
/usr/java/jdk1.3.1/jre/lib/i386/classic/libjvm.so: undefined reference to `jdk_pthread_sigmask'
libjava.so: undefined reference to `fork1'
libjava.so: undefined reference to `jdk_sem_wait'
libjava.so: undefined reference to `jdk_sem_init'
and ldd libjava.so gives me:
libjvm.so => /usr/java/jdk1.3.1/jre/lib/i386/classic/libjvm.so (0x40029000)
libverify.so => /usr/java/jdk1.3.1/jre/lib/i386/libverify.so (0x400bc000)
libnsl.so.1 => /lib/libnsl.so.1 (0x400cf000)
libdl.so.2 => /lib/libdl.so.2 (0x400e5000)
libc.so.6 => /lib/libc.so.6 (0x400ea000)
libm.so.6 => /lib/libm.so.6 (0x401df000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
I followed a suggestion from one posting and added the path to libjava.so (/usr/java/jdk/jre/lib/i386) to my /etc/ld.so.conf file and ran ldconfig.
I always stop and start Apache after every change and get very similar error messages..
Hope someone can help, I've already spent far far too much time doing this!
Many thanks
Hello Paul,
i use sun jdk1.3.1, apache1.3.20 and php4.0.5 on SUSE Linux 6.4.
Here are my steps:
in /usr/local/php
./configure --with-apxs=/usr/local/apache/bin/apxs --with-java=/usr/local/jdk1.3.1
--enable-track-vars
make
make install
cp php.ini-dist /usr/local/lib/php.ini
cd /usr/local/lib
vi php.ini
...
extension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20001222/
...
extension=libphp_java.so
...
[Java]
java.class.path = /usr/local/lib/php_java.jar:/usr/local/jdk1.3.1/jre/lib/rt.jar
java.home = /usr/local/jdk1.3.1
java.library = /usr/local/jdk1.3.1/jre/lib/i386/hotspot/libjvm.so
java.library.path = /usr/local/lib/php/extensions/no-debug-non-zts-20001222:
/usr/local/jdk1.3.1/jre/lib/i386:
/usr/local/jdk1.3.1/jre/lib/i386/hotspot:
/usr/local/jdk1.3.1/jre/lib/i386/native_threads (all in one line)
So it works on my system.
If i try:
<?php
$system = new Java("java.lang.System");
echo "Seconds since 01/01/1970: [".$system->currentTimeMillis()."]";
flush();
?>
I get:
Seconds since 01/01/1970: [992517853337]
Hope it helps, best regards
Matthias
putremos
06-14-2001, 06:33 AM
I wish I could bin my Cobalt server and run Suse :(
I've just been trying again for the last 1/2 hours using the same setup and it still doesn't work.. If I call up a php script in the browser it just times out eventually.
I've got to do some reading.. I'm not sure the difference between classic, native_threads, green_threads, etc. I think the JDK version has something to do with it:
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Classic VM (build 1.3.1-b24, green threads, nojit)
Does this reflect anyone elses version? If my JDK prefers to use green threads do I need to alter any of my php/path settings?
Depressed...
Thanks for your help
Hello Paul,
this is my java version:
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
I downloaded it from sun some days ago.
Don't worry,
Matthias
putremos
06-14-2001, 08:01 AM
Hi Matthias
Thanks for your moral support :)
I'm going to try and mirror your setup exactly but i'm not sure yet how to set the JVM to use Hotspot Client VM by default all the time i.e. you can switch it at the command line like: java -hotspot but you have to specify a class there and then.. could be in a cfg file somewhere, more hacking!
feel like i'm on a trampoline..
Hello Paul,
there is a jvm.cfg file in my /usr/local/jdk1.3.1/jre/lib directory.
The first entry sets the default Java VM. It is set to -client on my system, but i think, client is the same as hotspot (hotspot links to client).
Please check this, may be it helps.
Matthias
putremos
06-14-2001, 09:12 AM
Excellent lead Matthias!
I put -client at the top of the list and java -version displays
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
so now I'm running almost the same configuration as you..
Still don't work though! :(
It still times out in a browser calling up jver.php or other simple scripts..
Thanks anyway, maybe I'll ask Cobalt for some advice (Ha!)
Does the jdk work on Cobalt? I know that Cobalt uses a MIPS architecture and I don't know of any jdk that comes compiled for MIPS. This might be the problem.
putremos
06-14-2001, 10:19 AM
Hi Charles
I'm using the very recently released Sun Cobalt JDK 1.3.1 which is built to run on a i386 type architecture (the Cubes and earlier than RaQ3 servers are MIPS)
I know i'm really close, does anyone know of a way to see whats going on while my webserver is toiling to serve me a PHP/Java page? I've checked out strace but can't get tell anything useful from it..
I'd be thinking about giving up right now if I could.
Hello Paul,
before you give up, please check this:
I've these lines in my /etc/ld.so.conf:
...
/usr/local/jdk1.3.1/jre/lib/i386
/usr/local/jdk1.3.1/jre/lib/i386/hotspot
/usr/local/jdk1.3.1/jre/lib/i386/navtive_threads
On my system it don't work without it!
Don't forget to run ldconfig if you have changed ld.so.conf.
Wish you much success,
Matthias
putremos
06-15-2001, 03:59 AM
Thanks Matthias, good suggestion again!
But after adding the paths to ld.so.conf and running ldconfig I'm still no further forward. If I run your little test script or jver.php the operation still times out in the browser.
I make sure my environment variables are set correctly every time i restart httpd, do you think I'm missing something there?
CLASSPATH=:.:/usr/java/jakarta-tomcat/lib/servlet.jar:/usr/interclient/interclient.jar:/usr/java/jdk/jre/lib/rt.jar
LD_LIBRARY_PATH=/usr/local/lib/php/extensions/no-debug-non-zts-20001222:/usr/java/jdk/jre/lib/i386:/usr/java/jdk/jre/lib/i386/hotspot:/usr/java/jdk/jre/lib/i386/native_threads
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/java/jdk/bin:/usr/java/jdk/jre/bin
and maybe you have a good idea on how to debug while my browser seems to be trying to do something?
yours gratefully
Paul
Hi Paul,
after reading your message i've an important question: Is it your aim to run php as a servlet with tomcat or do you run apache (or something else ) as webserver an php is a module of it and your php-scripts do something like $obj=new Java(...).
If first: Since one week I try it too, it does not run yet, but i'm hopeful.
if second: add some echo and flush commands to your script; comment out your "new Java()"-line and check what happens.
Matthias
Hello
I am tring to Use PHP and Java.
I wanna use all the Java classes from php.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I start searching on the web about this topic and found this page.
I am using jdk1.3.1, apache1.3.20 and php4.0.6 on Redhat7.1
I follow all the step written by Mr.Matthias
and
tried the example Mr.Matthias gave.
As follow.
<?php
$system = new Java("java.lang.System");
echo "Seconds since 01/01/1970: [".$system->currentTimeMillis()."]";
flush();
?>
and I get:
Fatal error: java.lang.NoClassDefFoundError: net/php/reflect in
/home/hello/java/time.php on line 2
hope someone can help me
hello,
I wrote to ask for help.
but after working for about 3 hours I manage to make it work...
But - what made it work???
After many frustrating hrs it finally works. The key is to use the hotspot jvm rather than the classic jvm. The hotspot jvm is designed for better performance in executing java code. Not sure why the classic jvm didn't work for me but the hotspot jvm works fine
Here is my system:
mandrake8.0
apache1.3.19
php4.1.1
sun microsystems jdk1.3.0_02
here are the steps to make this work: (check the paths to make sure they are the same on your system)
./configure --with-apxs --with-java ...other config options...
make
make install
LD_LIBRARY_PATH={PATH-TO-JDK}/jre/lib/i386/hotspot:{PATH-TO-JDK}/jre/lib/i386
export LD_LIBRARY_PATH
PATH=$PATH:{PATH-TO-JDK}
export PATH
CLASSPATH={PATH-TO-JDK}/jre/lib/rt.jar
export CLASSPATH
add this to /etc/ld.so.conf, you don't have to put this here, does the same thing as setting the LD_LIBRARY_PATH environment variable but you have to set LD_LIBRARY_PATH everytime you reboot if you don't put it in ld.so.conf
{PATH-TO-JDK}/jre/lib/i386/hotspot
{PATH-TO-JDK}/jre/lib/i386
[JAVA] of php.ini
java.class.path = /usr/local/lib/php/php_java.jar
java.home = /usr/java/jdk1.3.0_02
java.library = {PATH-TO-JDK}/jre/lib/i386/hotspot/libjvm.so
;java.library.path =
extension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20010901
extension=libphp_java.so
apachectl restart ...et voila!
email me if you have any questions. Good luck!
oops meant to post this at the end
After many frustrating hrs it finally works. The key is to use the hotspot jvm rather than the classic jvm. The hotspot jvm is designed for better performance in executing java code. Not sure why the classic jvm didn't work for me but the hotspot jvm works fine
mandrake8.0
apache1.3.19
php4.1.1
jdk1.3.0_02
./configure --with-apxs --with-java ...other config options...
make
make install
LD_LIBRARY_PATH={PATH-TO-JDK}/jre/lib/i386/hotspot:{PATH-TO-JDK}/jre/lib/i386
export LD_LIBRARY_PATH
PATH=$PATH:{PATH-TO-JDK}
export PATH
CLASSPATH={PATH-TO-JDK}/jre/lib/rt.jar
export CLASSPATH
add this to /etc/ld.so.conf, you don't have to put this here, does the same thing as setting the LD_LIBRARY_PATH environment variable but you have to set LD_LIBRARY_PATH everytime you reboot if you don't put it in ld.so.conf
{PATH-TO-JDK}/jre/lib/i386/hotspot
{PATH-TO-JDK}/jre/lib/i386
[JAVA] of php.ini
java.class.path = /usr/local/lib/php/php_java.jar
java.home = /usr/java/jdk1.3.0_02
java.library = {PATH-TO-JDK}/jre/lib/i386/hotspot/libjvm.so
;java.library.path =
extension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20010901
extension=libphp_java.so
apachectl restart ...et voila!
PHP Builder
Copyright Internet.com Inc. All Rights Reserved.