|
From: <php...@li...> - 2007-04-30 16:24:21
|
Hey Jost --
Thanks for your time on this.
Hrm, this is frustrating. I put this together and received a "Call to
undefined function java()" error (see full error below):
require_once("/usr/java/tomcat-5.5/webapps/JavaBridge/java/Java.inc");
$passwd=3D"admin";
try {
java_require("file:/usr/lib/php/modules/lib/mail.jar"); // mail.jar is
not part of the standard jdk
$password=3Dnew java("java.lang.String", "$passwd");
=20
$algorithm=3D java("java.security.MessageDigest")->getInstance("md5");
$algorithm->reset();
$algorithm->update($password->getBytes());
$encrypted =3D $algorithm->digest();
$out =3D new java("java.io.ByteArrayOutputStream");
$encoder =3D
java("javax.mail.internet.MimeUtility")->encode($out,"base64");
$encoder->write($encrypted);
$encoder->flush();
echo new java("java.lang.String",$out->toByteArray()); echo "\n";
exit(0);
} catch (Exception $e) {
echo "Echo invocation failed: $e\n";
print_r ($e->getTrace());
exit(1);
}
Error:=20
_________________________________
type Exception report
message
description The server encountered an internal error () that prevented
it from fulfilling this request.
exception
javax.servlet.ServletException: PHP Fatal error: Call to undefined
function java() in /usr/java/tomcat-5.5/webapps/JavaBridge/mytest.php on
line 3
php.java.servlet.PhpCGIServlet.doGet(PhpCGIServlet.java:362)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
php.java.bridge.Util$ProcessWithErrorHandler$PhpException: PHP Fatal
error: Call to undefined function java() in
/usr/java/tomcat-5.5/webapps/JavaBridge/mytest.php on line 3
=09
php.java.bridge.Util$ProcessWithErrorHandler.destroy(Util.java:899)
=09
php.java.servlet.PhpCGIServlet$CGIRunner.run(PhpCGIServlet.java:284)
php.java.servlet.CGIServlet.doGet(CGIServlet.java:463)
php.java.servlet.PhpCGIServlet.doGet(PhpCGIServlet.java:328)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
________________________________________
It seems to not find the objects within Java.inc, however it's including
the file properly in the script so therefore I am considering that I
don't have the Bridge installed properly. =20
I've followed the j2ee instructions to install the bridge as I want
Tomcat to run the JVM rather than a new JVM trying to run each request.
Is this incorrect? Does a JVM have to start every time anyway? I'm
running this on a Virtual Dedicated Hosting account and therefore it's
not my own server to run as I please. =20
When I try to run this on the command line:=20
java -jar JavaBridge.war --help
I get this error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
I thought I installed the Bridge without the need to create a new JVM
each time, but again perhaps I'm not understanding how this works... :/
When first installing the bridge I struggled with attempting to increase
the amount of memory available to the JVM, but gave up and went what I
thought was the pure PHP installation.
I've got JavaBridge.war and the unpacked JavaBridge directory in my
tomcat webapps directory. I can run the test.php file and the examples
provided (the hello.php and numberguess.php scripts) by browsing here:
http://mydomain.com:9080/JavaBridge/hello.php or
http://mydomain:9080/JavaBridge/numberguess.php, respectively).
I've saved java.so to the php-extension directory and put a reference
(extension=3Djava.so) in the java.ini file in my /etc/php.d/ directory =
and
verified that php was looking in this directory for user-defined ini
settings.
Thanks for helping me with this...
--Kate
|