From: <php...@li...> - 2007-04-26 17:12:01
|
Hi folks ? This may be out of scope of the PJB project, but I?m having some =20 trouble translating Java into PHP and this is because I?m rather new =20 at Java (it?s been a trial, to say the least!). I?m trying to figure out why a string encoding function in Java would =20 return a different value as a seemingly logical reproduction in PHP. =20 It doesn?t make sense to me so I?m trying to see what the Java =20 function will return via PHP first, but I?m having issues. If this =20 isn?t too off-topic, please keep reading? 1: a java application takes the string ?admin? and turns it into a =20 hash via md5 and then encodes it via base64 ? and comes up with this: ISMvKXpXpadDiUoOSoAfww=3D=3D 2: instructions from the developers of this application write ?There =20 are 2 parts to the password, one is the hash, the second is you need =20 to Base64 encode that hash.? 3: I ran the string ?admin? through md5() and then ran that through =20 base64_encode() functions in php. So base64_encode(md5(?admin)), =20 effectively. I receive this value: =20 MjEyMzJmMjk3YTU3YTVhNzQzODk0YTBlNGE4MDFmYzM=3D 4: The different return values are confusing me. 5: I have grabbed code provided as an example with their application =20 and it reads like this: import java.io.*; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.mail.MessagingException; import javax.mail.internet.MimeUtility; ? other stuff snipped private static String encodePassword(String password) { MessageDigest algorithm; try { algorithm =3D MessageDigest.getInstance(ENCRYPTION_TYPE); algorithm.reset(); algorithm.update(password.getBytes()); byte[] encrypted =3D algorithm.digest(); ByteArrayOutputStream out =3D new ByteArrayOutputStream(); OutputStream encoder =3D MimeUtility.encode(out, ENCODING_TYPE)= ; encoder.write(encrypted); encoder.flush(); return new String(out.toByteArray()); } catch (NoSuchAlgorithmException e) { return "Bad Encryption"; } catch (MessagingException e) { return "Bad Encryption"; } catch (IOException e) { return "Bad Encryption"; } } I translated this as: $password =3D "admin"; print "encoded: ". encodePassword($password)."<br>"; function encodePassword($password) { $message =3D new Java('java.security.MessageDigest'); $str =3D new Java('java.lang.String'); try { $algorithm =3D $message->getInstance('md5'); $reset =3D $algorithm->reset(); $update =3D $algorithm->update($str->getBytes($password)); //$update =3D $algorithm->update($password); $encrypted =3D $algorithm->digest(); $mu =3D new java('javax.mail.internet.MimeUtility'); $out =3D new Java('java.io.ByteArrayOutputStream'); $encoder =3D $mu->encode($out, 'base64'); $encoder->write($encrypted); $encoder->flush(); return $out->toByteArray(); } catch (Exception $e) { print_r($e); // for debugging purposes return "<br>Bad Encryption"; } } And I get this in response: JavaException Object ( [message:protected] =3D> [string:private] =3D> =20 [code:protected] =3D> 0 [file:protected] =3D> =20 /usr/java/tomcat-5.5/webapps/JavaBridge/test_class.php =20 [line:protected] =3D> 25 [trace:private] =3D> Array ( [0] =3D> Array ( =20 [file] =3D> /usr/java/tomcat-5.5/webapps/JavaBridge/test_class.php =20 [line] =3D> 25 [function] =3D> __call [class] =3D> Java [type] =3D> -> [args= ] =20 =3D> Array ( [0] =3D> getBytes [1] =3D> Array ( [0] =3D> admin ) ) ) [1] =3D= > =20 Array ( [file] =3D> =20 /usr/java/tomcat-5.5/webapps/JavaBridge/test_class.php [line] =3D> 25 =20 [function] =3D> getBytes [class] =3D> Java [type] =3D> -> [args] =3D> Array = ( =20 [0] =3D> admin ) ) [2] =3D> Array ( [file] =3D> =20 /usr/java/tomcat-5.5/webapps/JavaBridge/test_class.php [line] =3D> 17 =20 [function] =3D> encodePassword [args] =3D> Array ( [0] =3D> admin ) ) ) ) = =20 encoded: Bad Encryption What I think this is telling me is that on line 25 (which is this: =20 $update =3D $algorithm->update($str->getBytes($password));) something is =20 amiss. Line 17 is the print out the encoded password line (print =20 "encoded: ". encodePassword($password)."<br>";), which is, obviously, =20 having issues. *Any* help as I?m trying to learn how to translate Java into PHP would =20 be smashingly appreciated. And please advise if this is totally out =20 of bounds for this forum. TIA, Kate ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. |
From: <php...@li...> - 2007-04-27 09:36:25
|
Hi, > algorithm.update(password.getBytes()); > $str = new Java('java.lang.String'); > $algorithm->update($str->getBytes($password)); the above PHP code creates a zero-length String and then calls "".getBytes(<password>). The getBytes() function needs a symbol as its argument or no argument at all, not a password. :) Your Java code translated into PHP is: <?php require_once("http://localhost:8080/JavaBridge/java/Java.inc"); $password=new String("$passwd"); $algorithm=java("java.security.MessageDigest")->getInstance(ENCRYPTION_TYPE); $algorithm->reset(); $algorithm.update($password->getBytes()); $encrypted = $algorithm->digest(); $out = new java("java.io.ByteArrayOutputStream"); $encoder = java("javax.mail.internet.MimeUtility")->encode(out, ENCODING_TYPE); $encoder->write(encrypted); $encoder.flush(); return new String(out.toByteArray()); ?> (not tested) Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever |
From: <php...@li...> - 2007-04-27 15:38:09
|
Vielen Dank, Jost. This is very helpful :) This project is my introduction to Java, so I'm learning how to interpret its default and imported classes as I go along (and it's the concept of an interface that is throwing me for a loop at the moment, at least regarding how to represent this in php). Question: this doesn't seem to be a php construct to me: $algorithm.update($password->getBytes()); I will test what you sent to me below and attempt to reconstruct this, but I thought I'd pose the question here of what this means in php (specifically the period -- I understand this as a Java (and Javascript and vbscript, etc) construct rather than the typical -> in php). Thanks for your help, Kate -----Original Message----- From: php...@li... [mailto:php...@li...] On Behalf Of php...@li... Sent: Friday, April 27, 2007 2:36 AM To: php...@li... Subject: Re: [Php-java-bridge-users] PHP Java Translation Help Hi, > algorithm.update(password.getBytes()); > $str =3D new Java('java.lang.String'); > $algorithm->update($str->getBytes($password)); the above PHP code creates a zero-length String and then calls "".getBytes(<password>). The getBytes() function needs a symbol as its argument or no argument at all, not a password. :) Your Java code translated into PHP is: <?php require_once("http://localhost:8080/JavaBridge/java/Java.inc"); $password=3Dnew String("$passwd"); $algorithm=3Djava("java.security.MessageDigest")->getInstance(ENCRYPTION_= T YPE); $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, ENCODING_TYPE); $encoder->write(encrypted); $encoder.flush(); return new String(out.toByteArray()); ?> (not tested) Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever ------------------------------------------------------------------------ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2007-04-27 17:14:31
|
I don't have much experience on Linux. I got this problem when installing java bridge on my linux box. The failed dependencies indicates it could not find php but I do have php 5.2.0. Could some one gives me an suggestion. Sudo -s #rpm --import RPM-GPG-KEY # rpm -i php-java-bridge-3.2.1-1.FC6.i386.rpm=20 error: Failed dependencies: libgcj.so.7rh is needed by php-java-bridge-3.2.1-1.i386 php >=3D 5.1.1 is needed by php-java-bridge-3.2.1-1.i386 rtld(GNU_HASH) is needed by php-java-bridge-3.2.1-1.i386 |
From: <php...@li...> - 2007-04-28 11:50:44
|
Hi, > installing java bridge on my linux box. The failed > dependencies > indicates it could not find php but I do have php > 5.2.0. You can install PHP 5.2.0 in your home directory or in some other temporary place. But this won't affect the computer operating system in any way. You need to install the appropriate php RPM. > # rpm -i php-java-bridge-3.2.1-1.FC6.i386.rpm > error: Failed dependencies: > libgcj.so.7rh is needed by > php-java-bridge-3.2.1-1.i386 > php >= 5.1.1 is needed by > php-java-bridge-3.2.1-1.i386 > rtld(GNU_HASH) is needed by > php-java-bridge-3.2.1-1.i386 These are exported by gcc-java and php. The command: yum install php java should fix this problem. BTW: The Linux RPM's are for RedHat and compatibles (Fedora, WhiteBox, CentOS, ...). They don't work on Novell Linux for example, on other Linux operating systems use the generic binary download instead. Regards, Jost Boekemeier __________________________________ Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever |
From: <php...@li...> - 2007-04-28 14:58:27
|
Thanks for responding to my post Jost. I fixed it by compiling and installing from the source code. -----Original Message----- From: php...@li... [mailto:php...@li...] On Behalf Of php...@li... Sent: Saturday, April 28, 2007 4:51 AM To: php...@li... Subject: Re: [Php-java-bridge-users] Unable to installphp-java-bridge-3.2.1-1.FC6.i386.rpm on Linux Hi, > installing java bridge on my linux box. The failed > dependencies > indicates it could not find php but I do have php > 5.2.0. =20 You can install PHP 5.2.0 in your home directory or in some other temporary place. But this won't affect the computer operating system in any way. You need to install the appropriate php RPM. > # rpm -i php-java-bridge-3.2.1-1.FC6.i386.rpm=20 > error: Failed dependencies: > libgcj.so.7rh is needed by > php-java-bridge-3.2.1-1.i386 > php >=3D 5.1.1 is needed by > php-java-bridge-3.2.1-1.i386 > rtld(GNU_HASH) is needed by > php-java-bridge-3.2.1-1.i386 These are exported by gcc-java and php. The command: yum install php java should fix this problem.=20 BTW: The Linux RPM's are for RedHat and compatibles (Fedora, WhiteBox, CentOS, ...). They don't work on Novell Linux for example, on other Linux operating systems use the generic binary download instead. Regards, Jost Boekemeier __________________________________ Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever ------------------------------------------------------------------------ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2007-04-27 22:55:50
|
Hi there -- Ok, I've been working on this a bit today, reading about how classes constructs are represented in Java and trying to understand the documentation itself regarding java.security.MessageDigest and I'm just not sure why it's not liking the update() call. Here's the code evolution so far: $password =3D new Java("java.lang.String","admin"); $md =3D new Java("java.security.MessageDigest"); $algorithm =3D $md->getInstance("md5"); $reset =3D $algorithm->reset(); $update =3D $md->update($password->getBytes()); $digest =3D $md->digest(); $out =3D new Java("java.io.ByteArrayOutputStream"); $encoder =3D new Java("javax.mail.internet.MimeUtility"); $encoder->encode($out,"base64"); $encoder->write($encrypted); $encoder->flush(); $the_return =3D new Java("java.lang.String",$out->toByteArray()); echo "output: ".$the_return->trim(); It tosses an exception at the $update call: javax.servlet.ServletException: PHP Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:MessageDigest]]->update([o:array_of_B]). Cause: java.lang.NoSuchMethodException: update([o:array_of_B]). Candidates: [] Responsible VM: 1.5.0_09@http://java.sun.com/" at: #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1106) #-4 php.java.bridge.Request.handleRequest(Request.java:342) #-3 php.java.bridge.Request.handleRequests(Request.java:388) #0 /usr/java/tomcat-5.5/webapps/JavaBridge/test_string.php(24): Java->__call('update', Array) #1 /usr/java/tomcat-5.5/webapps/JavaBridge/test_string.php(24): Java->update(Object(JavaArray)) #2 {main}] thrown in /usr/java/tomcat-5.5/webapps/JavaBridge/test_string.php on line 24 php.java.servlet.PhpCGIServlet.doGet(PhpCGIServlet.java:362) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) Upon printing $password->getBytes() to the screen it simply resolves, naturally, to admin. This is correct, I assume, as it's just supposed to change the series of bytes to the systems character set. =20 So, what is deal?=20 Thanks in advance, Kate -----Original Message----- From: php...@li... [mailto:php...@li...] On Behalf Of php...@li... Sent: Friday, April 27, 2007 2:36 AM To: php...@li... Subject: Re: [Php-java-bridge-users] PHP Java Translation Help Hi, > algorithm.update(password.getBytes()); > $str =3D new Java('java.lang.String'); > $algorithm->update($str->getBytes($password)); the above PHP code creates a zero-length String and then calls "".getBytes(<password>). The getBytes() function needs a symbol as its argument or no argument at all, not a password. :) Your Java code translated into PHP is: <?php require_once("http://localhost:8080/JavaBridge/java/Java.inc"); $password=3Dnew String("$passwd"); $algorithm=3Djava("java.security.MessageDigest")->getInstance(ENCRYPTION_= T YPE); $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, ENCODING_TYPE); $encoder->write(encrypted); $encoder.flush(); return new String(out.toByteArray()); ?> (not tested) Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever ------------------------------------------------------------------------ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2007-04-28 11:41:58
|
Hi, I've used the following code: <?php require_once("http://localhost:8080/JavaBridge/java/Java.inc"); $passwd="hello"; try { java_require("mail.jar"); // mail.jar is not part of the standard jdk $password=new java("java.lang.String", "$passwd"); $algorithm=java("java.security.MessageDigest")->getInstance("md5"); $algorithm->reset(); $algorithm->update($password->getBytes()); $encrypted = $algorithm->digest(); $out = new java("java.io.ByteArrayOutputStream"); $encoder = 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); } ?> The above PHP script returns the encoded "hello" string. > about how classes > constructs are represented in Java and trying to The java function is a thin wrapper around the JavaClass constructor. It is defined in Java.inc as: function java($clazzName) { static $cache; if($cache) return $cache; return $cache=new JavaClass($clazzName); } > $md = new Java("java.security.MessageDigest"); Although our plan was to stop development after the 4.0.8 release, I think it makes sense to add another 4.1.1 release which immediately throws an exception when the above construct is called. At the moment the bridge only writes a warning message and only if the log level is >= 3. The check could be relaxed and turned into a warning when -Dphp.java.bridge.enable_deprecated=true is set (for backward compatibility). > [[o:Exception]:"java.lang.Exception: Invoke failed: > [[c:MessageDigest]]->update([o:array_of_B]). Cause: > java.lang.NoSuchMethodException: The bridge message is correct. There is no static "update" method in the MessageDigest class. I think your Java example uses $algorithm->update(), not $md->update(). Regards, Jost Boekemeier Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem neuen Yahoo! Mail. www.yahoo.de/mail |
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 |
From: <php...@li...> - 2007-04-30 17:07:57
|
Hi, > Hrm, this is frustrating. I put this together and > received a "Call to > undefined function java()" error (see full error > below): It is defined in Java.inc as: function java($clazz) { static $cache; if(isset($cache)) return $cache; return $cache=new JavaClass($clazz); } The function is handy because it hides the class variable inside the function. The code: $System = new JavaClass("java.lang.System"); $systemProps = $System->getProperties(); is equivalent to: $systemProps=java("java.lang.System")->getProperties(); but the latter is easier to read. > It seems to not find the objects within Java.inc, Hmm, when you use the java.so or php_java.dll, some old versions of Java.inc don't define this function. It may make sense to implement the function directly in java.c. > however it's including > the file properly in the script so therefore I am > considering that I > don't have the Bridge installed properly. Mea culpa. I thought that you use the pure PHP implementation. Just remove the java.so and the script will work. > 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. Correct. > Is this incorrect? Does a JVM have to start every > time anyway? Well, you have two options, a) start Java as a sub process of Apache or IIS (not recommended, needs java.so) or b) start Java via a J2EE server or servlet engine as a system service (recommended). On Windows/Unix you can start tomcat as a service. > running this on a Virtual Dedicated Hosting account > and therefore it's > not my own server to run as I please. Hmm. Do you get a notification when the computer boots? You can start a persistent java VM with nohup java -jar JavaBridge.jar <port> 3 jb.log& but the above VM will terminate when the computer reboots. > When I try to run this on the command line: > java -jar JavaBridge.war --help In which documentation have you found the above command? The .war file is a web archive, not an executable jar file. We could change that in the future, though. > I've saved java.so to the php-extension directory ------- nak, nak, nak. Remove it, please. :) The java.so contains code which could make the communication faster. But it is quite difficult to handle, especially for beginners. Regards, Jost Boekemeier __________________________________ Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever |
From: <php...@li...> - 2007-04-30 17:44:41
|
Hi there -- Yes, I read and understand the function below and changed my script in an attempt to utilize the JavaClass option as a test, but received the same exception as a few days ago, which was that update() didn't exist: function java($clazz) { static $cache; if(isset($cache)) return $cache; return $cache=3Dnew JavaClass($clazz); } $algorithm =3D java("java.security.MessageDigest"); $algorithm->getInstance("md5"); $algorithm->reset(); $algorithm->update($password->getBytes());=20 In other various tests it would toss a "reset() doesn't exist" exception, etc etc.=20 But rather than this as an issue, I think it's looking more like a problem with my Bridge install. I've removed the java.so from /etc/php.d/java.ini and now I'm receiving the error that sent me in many different directions to get this to work :) "PHP 5.0.4 too old. For PHP versions < 5.1.4 install the java.so or php_java.dll from the php-java-bridge-legacy download. Or set the path to the PHP executable, see php_exec in the WEB-INF/web.xml" I have set the path to my php executable in /usr/java/tomcat-5.5/webapps/JavaBridge/WEB-INF/web.xml as follows: <!-- Your php binary. Default is /usr/bin/php-cgi or --> <!-- c:/php/php-cgi.exe --> <!-- <init-param> <param-name>php_exec</param-name> <param-value>/usr/bin/php</param-value> </init-param> --> I also tried /usr/bin/php-cgi as suggested in the file, though when I read "php binary" I think of /usr/bin/php, not php-cgi. Please correct me if I'm wrong. Both binaries exist and both paths toss the same error. When I run 'which php' I get '/usr/bin/php' I cannot upgrade the php install. >> When I try to run this on the command line:=20 >> java -jar JavaBridge.war --help > In which documentation have you found the above > command? The .war file is a web archive, not an > executable jar file. We could change that in the > future, though. Sorry, was a typo on my part on the command line, though using .jar affects the same response. The command doesn't even get far enough to toss an error relative to the file type. > The java.so contains code which could make the > communication faster. But it is quite difficult to > handle, especially for beginners. And a beginner with Java I am, indeed. =20 Thanks for your help! K |
From: <php...@li...> - 2007-05-01 12:01:24
|
Hi, which version of the bridge do you use? > same exception as a few days ago, which was that > update() didn't exist: Yes, I've seen the message. However, the message was correct, update is not a static feature of the class. > In other various tests it would toss a "reset() > doesn't exist" How does the code look like? Do you see the reset() function when you call echo java_inspect($obj); I think you've confused the class and the instance. > I have set the path to my php executable in > /usr/java/tomcat-5.5/webapps/JavaBridge/WEB-INF/web.xml > as follows: > > <!-- Your php binary. Default is /usr/bin/php-cgi or > --> > <!-- c:/php/php-cgi.exe --> > <!-- > <init-param> > <param-name>php_exec</param-name> > <param-value>/usr/bin/php</param-value> > </init-param> > --> What do you mean with this? The init-param is still commented out!?! This is a misunderstanding, anyway. The J2EE component uses the built-in php-cgi.exe, which is 5.1.4. But you want to use Apache or IIS as a front end and the PHP version installed there. I didn't know that you use an old version of PHP, sorry. > When I run 'which php' I get '/usr/bin/php' Irrelevant. The Apache binary uses a dll/shared object. > Sorry, was a typo on my part on the command line, > though using .jar > affects the same response. The command doesn't even > get far enough to > toss an error relative to the file type. Too bad. Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Stellen Sie Fragen und finden Sie Antworten. Teilen Sie Ihr Wissen. www.yahoo.de/clever |
From: <php...@li...> - 2007-05-01 15:52:44
|
I appreciate your attempt to help with this, but the documentation and my lack of Java knowledge is becoming tedious. I get this message when running the script that you and I have been sending back and forth: --------------------- PHP 5.0.4 too old. For PHP versions < 5.1.4 install the java.so or php_java.dll from the php-java-bridge-legacy download. Or set the path to the PHP executable, see php_exec in the WEB-INF/web.xml --------------------- The web.xml file lists this php_exec under a section titled "PHP CGI servlet: when IIS or Apache are not available" and I have put the php binary as a value (uncommented). =20 What I don't get is that Apache *is* available, so why is the documentation steering me towards this implementation? Please explain. I do not understand how PHP deals with Java's instances. I do understand objects and classes from a PHP perspective, but I have just begun to learn Java so this process has a learning curve for me. Try to be open-minded. I installed this: php-java-bridge-4.0.7_j2ee and though the environment is a virtual dedicated server, my rights are sadly limited. If I could update php I would. I've got tomcat running on autostart and have the bridge in its webapps directory. =20 If tomcat is supplying the VM, why am I getting stack heap issues in trying to start a VM when merely calling java -jar JavaBridge.jar --help ? This has *got* to work, I just need to figure out how... --K |
From: <php...@li...> - 2007-05-02 09:14:37
|
Hi, > --------------------- > PHP 5.0.4 too old. > For PHP versions < 5.1.4 install the java.so or > php_java.dll from the > php-java-bridge-legacy download. > Or set the path to the PHP executable, see php_exec > in the > WEB-INF/web.xml > --------------------- > What I don't get is that Apache *is* available, so > why is the > documentation steering me towards this > implementation? Please explain. Depending on whether you use the Apache front-end or the J2EE back-end directly, a) you need to install the java.so/php_java.dll or b) set the path to the php executable, respectively. That is: http://localhost:8080/JavaBridge/test.php invokes the php_exec from the web.xml, http://localhost:80/JavaBridge/test.php invokes Apache or IIS and triggers the php.so or php.dll which in turn reads the php.ini which in turn loads the java.so or php_java.dll. > I do not understand how PHP deals with Java's > instances. Well, as someone else noted, your only mistake was that you thought that getInstance evaluates for its side effects. But this isn't the case. It is a function. > I installed this: php-java-bridge-4.0.7_j2ee and Okay. > though the environment > is a virtual dedicated server, my rights are sadly > limited. Okay. > I've got tomcat running on autostart and have the > bridge in its webapps > directory. Okay. This means that even if the machine boots, tomcat (and the bridge) will re-start automatically. Good. > If tomcat is supplying the VM, why am I getting > stack heap issues in Your ISP doesn't want you to start java from the console. This is usually a GRSecurity or SEL issue. > trying to start a VM when merely calling java -jar > JavaBridge.jar --help > ? > > This has *got* to work, I just need to figure out > how... Not really. You can restrict Java so that it core dumps on startup. Please take a look at the SEL files distributed with the php-java-bridge source download. Sun JDK 1.5 for example creates executable files in the temp dir with global permissions. This is very insecure, imho. If you switch off these permissions via a SEL rule, Java will crash in the garbage collector or in the JIT thread. It all depends on the SEL context. Presumably tomcat runs in the initd_t context, not in unconfined_t. But that's guesswork. Regards, Jost Boekemeier Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem neuen Yahoo! Mail. www.yahoo.de/mail |
From: <php...@li...> - 2007-05-01 12:16:41
|
Hi, > And a beginner with Java I am, indeed. Isn't it possible to test your scripts on a local computer? When they work, you can create a web archive (.war file) and deploy it into the Tomcat/J2EE server of your ISP. After that symlink or copy the scripts from the tomcat webapps directory to the Apache or IIS document root and you're done. Regards, Jost Boekemeier __________________________________ Kennt man wirklich jeden über 3 Ecken? Die Antworten gibt's bei Yahoo! Clever. www.yahoo.de/clever |
From: <php...@li...> - 2007-05-01 14:06:39
|
$algorithm = java("java.security.MessageDigest"); $algorithm->getInstance("md5"); $algorithm->reset(); As far as I understood the discussion this should be $algo = java(...)->getInstance(...). You want to reset the algorithm, not the class, no? 8=) --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos. |
From: <php...@li...> - 2007-04-27 09:39:17
|
Hi again, BTW: > } catch (Exception $e) { > > print_r($e); // for debugging purposes > return "<br>Bad Encryption"; The PHP Exception objects already provide a suitable __toString() method. The output from print($e) is much more readable than the output from print_r($e), which prints the internal state of the exception object. Regards, Jost Boekemeier Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem neuen Yahoo! Mail. www.yahoo.de/mail |
From: <php...@li...> - 2007-04-27 15:38:37
|
This I did not know, so thank you. --Kate -----Original Message----- From: php...@li... = [mailto:php...@li...] On Behalf = Of php...@li... Sent: Friday, April 27, 2007 2:39 AM To: php...@li... Subject: Re: [Php-java-bridge-users] PHP Java Translation Help Hi again, BTW: > } catch (Exception $e) { >=20 > print_r($e); // for debugging purposes > return "<br>Bad Encryption"; The PHP Exception objects already provide a suitable __toString() method.=20 The output from print($e) is much more readable than the output from print_r($e), which prints the internal state of the exception object. Regards, Jost Boekemeier Heute schon einen Blick in die Zukunft von E-Mails wagen? = Versuchen Sie=B4s mit dem neuen Yahoo! Mail. www.yahoo.de/mail -------------------------------------------------------------------------= This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |