|
From: <php...@li...> - 2008-09-22 13:56:39
|
Dear all,
I am new to the PHP/Java bridge and trying to run the standard examples. I'm
trying to connect Java 1.6.0.6 with PHP 5.2.2 to call PHP from JAVA using
the scripting engine. The installation itself via the copy statement was
fine. I tried two options, in both cases the code compiles and seems to
connect to the PHP engine,but the results are not as hoped for:
// OPTION 1
javax.script.ScriptEngineManager manager = new
javax.script.ScriptEngineManager();
javax.script.ScriptEngine e = manager.getEngineByName("php-invocable");
e.eval("<?php class f {function a($p) {return java_values($p)+1;}}\n" +
"java_context()->setAttribute('f', java_closure(new f()), 100); ?>");
javax.script.Invocable i = (javax.script.Invocable)e;
Object f = e.getContext().getAttribute("f", 100);
System.out.println("Invoking");
String res = (String) i.invokeMethod(f, "a", new Object[] {new Integer(1)});
Sytem.out.println("Output: " + res);
e.eval ((java.io.Reader) null);
This leads to a null pointer exception after printing the line 'invoking'
when trying to call invokeMethod. That is, locating the 'f' function does
not lead to an object.
OPTION 2
System.out.println("Interactive engine");
javax.script.ScriptEngine e2 = (new
javax.script.ScriptEngineManager()).getEngineByName("php-interactive");
e2.eval("$v = 1+2");
System.out.println(e2.eval("echo $v"));
e2.eval((String)null);
This leads to a stack overflow exception:
Exception in thread "main" java.lang.StackOverflowError
at
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:97)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
at
php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:91)
at
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:97)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
at
php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:91)
at
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:97)
and etceteras
Any suggestions here on what I'm doing wrong?
Thanks already for any suggestions you can provide!
Kind regards,
Bart Orriens
The new is always the old. Everything that's old was once new, and
everything that's new will one day be old. The oldest thing of all is the
present, because there's never been anything else but the present. No one
has ever lived in the past, and no one lives in the future, either.
|
|
From: <php...@li...> - 2008-09-22 20:49:44
|
Hi,
I am sorry, but I could not reproduce these problems. The bridge works fine unless you try to mix different versions or even different libraries.
Which version of the bridge do you use? Are you sure that you use the PHP/Java Bridge or do you use something else?
Can you please post the results of the following calls:
jrunscript -classpath JavaBridge.jar -l php-interactive
> echo java("php.java.bridge.Util")->VERSION
Can you please deploy the standard JavaBridge.war and click on the jsr223.jsp and php+jsp.jsp examples?
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2008-09-23 11:34:43
|
Hi Jost, the version I am using is from the PHP/JavaBridge web site, entitled php-java-bridge_5.2.2_j2ee.zip. I re-did the installation procedure and tested the result.html page. I receive the output correctly there: BEGIN Starting a simple servlet engine: [C:\Program Files\Java\jre1.6.0_07\bin\java, -jar, C:\Data\RAND\MMIC\java php bridge\php-java-bridge_5.2.2_j2ee\ext\JavaBridge.jar, SERVLET_LOCAL:8081] Sep 23 12:56:55 VMBridge INFO : VM : 1.6.0_07@ http://java.sun.com/ Sep 23 12:56:55 VMBridge INFO : VMBridge version : 5.2.2 Sep 23 12:56:55 VMBridge INFO : logFile : Sep 23 12:56:55 VMBridge INFO : default logLevel : 3 Sep 23 12:56:55 VMBridge INFO : socket : SERVLET_LOCAL:8081 Sep 23 12:56:55 VMBridge INFO : java.ext.dirs : C:\Program Files\Java\jre1.6.0_07\lib\ext;C:\Windows\Sun\Java\lib\ext Sep 23 12:56:55 VMBridge INFO : php.java.bridge.base: C:\Users\bartorriens Sep 23 12:56:55 VMBridge INFO : thread pool size : 20 Sep 23 12:56:55 VMBridge INFO : JavaBridgeRunner started on port INET_LOCAL:8081 Invoking php: [php-cgi, -n, -d, allow_url_include=On, C:\Data\RAND\MMIC\java php bridge\php-java-bridge_5.2.2_j2ee\test.php] Now check the C:\Data\RAND\MMIC\java php bridge\php-java-bridge_5.2.2_j2ee\RESULT.html. Read the INSTALL.J2EE and/or INSTALL.J2SE documents. END I then copied the javabridge.jar and php-script.jar to the JRE lib/ext directory. Next I attempted to deploy the standard WAR file to Apache Tomcat (running on port 8081) using the Tomcat's applications manager. However, I got the error FAIL - Application at context path /JavaBridge could not be started I also attempted to run examples found in the 'documentation/server/test' directory using NetBeans IDE, specifically the helloworld.java code and the simpleinvocation.java code. In both cases the result when running it is: Exception in thread "main" java.lang.NullPointerException at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:636) at php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:116) at php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:100) at php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108) The Jscript I attempted to use, but it is not recognized as a valid command under Vista. It should be created during installation? Any help on what I'm doing wrong here/left out to do would be much appreciated! Kind regards, Bart On Mon, Sep 22, 2008 at 10:49 PM, < php...@li...> wrote: > Hi, > > I am sorry, but I could not reproduce these problems. The bridge works fine > unless you try to mix different versions or even different libraries. > > Which version of the bridge do you use? Are you sure that you use the > PHP/Java Bridge or do you use something else? > > > Can you please post the results of the following calls: > > jrunscript -classpath JavaBridge.jar -l php-interactive > > > echo java("php.java.bridge.Util")->VERSION > > > Can you please deploy the standard JavaBridge.war and click on the > jsr223.jsp and php+jsp.jsp examples? > > > Regards, > Jost Boekemeier > > > __________________________________________________ > Do You Yahoo!? > Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz > gegen Massenmails. > http://mail.yahoo.com > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > -- The new is always the old. Everything that's old was once new, and everything that's new will one day be old. The oldest thing of all is the present, because there's never been anything else but the present. No one has ever lived in the past, and no one lives in the future, either. |
|
From: <php...@li...> - 2008-09-23 19:27:14
|
Hi,
You have mentioned that you have "compiled" the code yourself. This may mean that you have compiled Java to native code and declared the compiled extension in the php.ini file.
When using the pure Java PHP/Java Bridge doesn't work if there's a php_java.dll or java.so or a java declaration in you php.ini file(s).
Version 5.2.2.3 contains a workaround for this problem,
please see the ChangeLog for details:
* server/php/java/script/SimplePhpScriptEngine.java (setNewContextFactory): The java.so
and php_java.dll must not trash the pure Java PHP/Java Bridge implementation. Override
any settings from the java.so or php_java.dll and use our own settings.
* VERSION, php-java-bridge.spec: Version 5.2.2.3 released
> FAIL - Application at context path /JavaBridge could not be
> started
This doesn't have anything to do with the PHP/Java Bridge. Please follow the standard procedure to create a clean environment and start again:
Please remove all Java libraries from the jre lib/ext directory and use a standard tomcat installation.
Then remove the work/Catalina and temp/* directories and restart tomcat. After that your (PHP/Java Bridge) Java web application will start properly.
If that doesn't work please check the tomcat log for any exceptions/error reports. The localhost*.log contains a detailed description why the web application could not be started. If you see ClassCastExceptions or class loader exceptions or errors there, make sure that your libraries are loaded from one place.
If that still doesn't work, please contact the tomcat developers.
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2008-09-24 19:03:09
|
Hi,
I followed your instructions to re-deploy the war file to apache tomcat at
port 8082 (Please remove all Java libraries from the jre lib/ext directory
and use a standard tomcat installation.Then remove the work/Catalina and
temp/* directories and restart tomcat. After that your (PHP/Java Bridge)
Java web application will start properly). Deployment is now successful, but
attempting to open any files in the directory JavaBridge (or this directory
itself) results in:
INFO: PHP application terminated unexpectedly, have you started php-cgi with
the environment setting PHP_FCGI_MAX_REQUESTS=5000? Trying again using a new
connection: php.java.servlet.fastcgi.ConnectionException
Sep 24, 2008 7:55:40 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet PhpCGIServlet threw exception
java.io.IOException: Protocol error
at
php.java.servlet.fastcgi.FastCGIInputStream.doRead(FastCGIInputStream.java:64)
at
php.java.servlet.fastcgi.FastCGIInputStream.read(FastCGIInputStream.java:51)
at
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.parseBody(FastCGIServlet.java:445)
at
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.doExecute(FastCGIServlet.java:371)
at
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.execute(FastCGIServlet.java:376)
at php.java.servlet.CGIServlet.handle(CGIServlet.java:400)
at php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:355)
at php.java.servlet.CGIServlet.doGet(CGIServlet.java:469)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
I also deployed the java bridge to a running Apache 2 server. There the
PHP_FCGI_MAX_REQUESTS is set to 10000, so that is not an issue. Pages can
then be accessed without the above error, but the only one working sort of
is the hello.php file. In the Apache error log it states though:
PHP Notice: Undefined index: language in C:\Program
Files\Zend\Apache2\htdocs\JavaBridge\hello.php on line 11
PHP Fatal error: Call to undefined function bindtextdomain() in C:\Program
Files\Zend\Apache2\htdocs\JavaBridge\hello.php on line 23
Clicking links to all other files leads to the error I mentioned in my
previous email:
===================================================================
protocol error: Method Not Allowed
The requested method PUT is not allowed for the URL
/JavaBridge/JavaBridge.phpjavabridge.
, Internal error at col 4. Check the back end log for details.
===================================================================
I get the same error when I simply access the JAVA/PHP bridge directory
running on localhost:8081 (which is the result of the installation of the
war file) and click the link to test.php.
About compiling the code: I did not include the php_java.dll in the php.ini
file. Also, there is no java related declaration in there. The only code I
compiled is the example code. To clarify perhaps: in the compiled code
option I compile the helloworld.java file in Netbeans IDE 6.0 and then try
to run the helloworld.java example (where I added the jar files to both the
jdk/jre directory and the jre directory of java 1.6.0_7 to run this code. As
said, I removed those files when testing usage via apache tomcat or apache
2). This then results in the mentioned:
Exception in thread "main" java.lang.NullPointerException
at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:636)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:116)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:100)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
It is this last one I am interested in most, as I want to call an existing
php based system from a stand-alone JAVA application. Any help to shed light
on all this would be really appreciated.
Perhaps the problem lies with my fastcgi settings of the php engine? The
settings of the fastcgi.conf file are:
Server type="application/x-httpd-php" CommandLine="C:\Program
Files\Zend\Core\bin\php-cgi.exe" ConnectionTimeout="30" RequestTimeout="60"
StartProcesses="8" Impersonate="1" SetEnv="PHP_FCGI_MAX_REQUESTS=10000"
SetEnv="PHP_FCGI_CHILDREN=1" SetEnv="PATH=?" SetEnv="TEMP=C:\Program
Files\Zend\Core\temp" SetEnv="OS=?" SetEnv="SystemRoot=?" SetEnv="ComSpec=?"
MinDynamicServers 8
MaxDynamicServers 16
IpcDir "C:\Program Files\Zend\Core\temp"
Thanks for all your efforts already!
Kind regards,
Bart
|
|
From: <php...@li...> - 2008-09-24 21:54:39
|
Hi, > the environment setting PHP_FCGI_MAX_REQUESTS=5000? Trying > again using a new connection: > CommandLine="C:\Program > Files\Zend\Core\bin\php-cgi.exe" > ConnectionTimeout="30" > RequestTimeout="60" > StartProcesses="8" Impersonate="1" > SetEnv="PHP_FCGI_MAX_REQUESTS=10000" > SetEnv="PHP_FCGI_CHILDREN=1" We're sorry, but we cannot support Zend products. Please contact Zend instead. The PHP/Java Bridge needs the settings described in the README: at least 5 childs and 5000 MAX_REQUESTS. You can change that in the web.xml, though. > I also deployed the java bridge to a running Apache 2 > server. There the > PHP_FCGI_MAX_REQUESTS is set to 10000, so that is not an What do you mean with that? Apache2 doesn't use fastcgi. > PHP Fatal error: Call to undefined function > bindtextdomain() in C:\Program > Files\Zend\Apache2\htdocs\JavaBridge\hello.php This is not a PHP/Java Bridge issue but a PHP issue. You must compile PHP with language support, otherwise bindtextdomain is not available. Please see your PHP documentation for details. > =================================================================== > protocol error: Method Not Allowed > > The requested method PUT is not allowed for the URL > /JavaBridge/JavaBridge.phpjavabridge. > , Internal error at col 4. Check the back end log for > details. You probably have some filter installed. For example mod_jk. You must allow PUT requests to the PHP/Java Bridge servlet, at least on the local interface, otherwise the front-end will not be able to connect to the servlet. Again, this is all working in a standard tomcat installation. You can its default settings, but you must know what you're doing. Regards, Jost Boekemeier __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com |
|
From: <php...@li...> - 2008-09-25 15:06:30
|
Hi,
I am short on time right now to sort out the PUT permission. I'll take
another look at it when I can. I AM using a standard tomcat installation to
which I deployed the war file, but obviously I'll need to re-configure PHP
to support PUT requests.
Putting that aside for a moment though, my main intention for using the
bridge would not be to write new PHP files containing a mix of php and
java-related code; where the php based front end calls a JAVA based backend.
I am solely interested really in the following:
- I have an existing PHP based application, both backend and frontend.
- I want to create a JAVA based front end that can talk to the PHP based
backend
In other words, I want to evaluate PHP code from a JAVA program using a PHP
script engine and use the results in the JAVA program. Preferable I want to
do this in such a way that no changes to the existing PHP code are needed
(i.e. no inclusion of java related constructs in the PHP code, etceteras),
however if this is the only way to do it I'll naturally consider it. Any
info on the exact support offered by the bridge would be nice.
Following the instructions in the Installation.J2SE file I did the following
to setup the bridge:
* Have Java 1.6.0_07.
* Have PHP 5.2.2.
* Downloaded and extracted the php-java-bridge_j2ee*.zip archive into a
folder and typed: java -classpath JavaBridge.war TestInstallation
* Copied the created "JavaBridge.jar" and "php-script.jar" from the
"ext" folder to the J2SE library path (specifically the 'jre/lib/ext'
directory)
* opened Netbeans IDE
* created the example in helloworld.java via Netbeans, being:
public class HelloWorld {
public static void main(String[] args) {
String l = "3";
System.setProperty("php.java.bridge.default_log_level", l);
System.setProperty("php.java.bridge.default_log_file", "");
System.setProperty("php.java.bridge.php_exec", "php-cgi");
try {
InvocablePhpScriptEngine engine = new InvocablePhpScriptEngine();
String s = "<?php
extension_loaded('java')||@dl('java.so')||@dl('php_java.dll'); echo
'HelloWorld!\n'; java_context()->call(java_closure())
||die('oops!');?>";
engine.eval(new StringReader(s));
String name = (String)
((Invocable)engine).invokeFunction("java_get_server_name", new Object[]{});
System.out.println("PHP/Java communication port: " + name);
}
//engine.release();
engine.eval((Reader)null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
* Compiled the code, which went fine
* Ran the code, leading to:
Exception in thread "main" java.lang.NullPointerException
at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:636)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:116)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:100)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
As a second test I also ran SimpleInvocation.java:
public class Main {
public static void main(String[] args) throws Exception {
ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine e = m.getEngineByName("php-invocable");
Invocable i = (Invocable)e;
i.invokeFunction("phpinfo", new Object[0]);
System.exit(0);
}
}
This leads to the same error.
What am I doing wrong? No php_java.dll is loaded in php.ini.
Thanks for any help,
Bart
|
|
From: <php...@li...> - 2008-09-25 19:39:12
|
Hi,
> I am short on time right now to sort out the PUT
> permission. I'll take
Just deinstall mod_jk and it should work.
> to re-configure PHP
> to support PUT requests.
Not really. Tomcat and the PHPJavaServlet do support put, get and post requests. However, when mod_jk is installed, which is a deprecated method to connect apache with tomcat, the back end denies PUT requests in order to disallow internet clients to modify the web content.
> java-related code; where the php based front end calls a
> JAVA based backend.
You have two options: either start the built-in servlet engine with java -jar JavaBridge.jar or use a real servlet engine, for example tomcat, jetty, Oracle, IBM WebSphere, ...
[the other way 'round...]
> - I have an existing PHP based application, both backend
> and frontend.
> - I want to create a JAVA based front end that can talk to
> the PHP based
> backend
That's trivial, if you use the JSR 223 API.
For example:
jrunscript -classpath JavaBridge.jar -l php-interactive
> function toString() {return "hello Java, I am PHP";}
> echo java_closure();
=> hello Java, I am PHP
[to run the above example make sure that JavaBridge.jar and php-script.jar
is in the current working directory and that jre/lib/ext does not contain
JavaBridge.jar and php-script.jar -- Java doesn't have a module system, please
see our README section Java Platform Issues for details. Use .NET or Mono if you
don't like how Java works around that problem... ]
> * Copied the created "JavaBridge.jar" and
> "php-script.jar" from the
> "ext" folder to the J2SE library path
> (specifically the 'jre/lib/ext'
> directory)
Right.
> * opened Netbeans IDE
[...]
> public class HelloWorld {
>
> public static void main(String[] args) {
>
> String l = "3";
>
> System.setProperty("php.java.bridge.default_log_level",
> l);
>
> System.setProperty("php.java.bridge.default_log_file",
> "");
>
> System.setProperty("php.java.bridge.php_exec",
> "php-cgi");
>
> try {
> InvocablePhpScriptEngine engine = new
> InvocablePhpScriptEngine();
> String s = "<?php
> extension_loaded('java')||@dl('java.so')||@dl('php_java.dll');
> echo
> 'HelloWorld!\n';
> java_context()->call(java_closure())
> ||die('oops!');?>";
>
> engine.eval(new StringReader(s));
> String name = (String)
> ((Invocable)engine).invokeFunction("java_get_server_name",
> new Object[]{});
> System.out.println("PHP/Java communication
> port: " + name);
>
> }
>
> //engine.release();
> engine.eval((Reader)null);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> * Compiled the code, which went fine
The above example contains a try/catch statement with two closing braces. Either netbeans is a really bad programming editor or the above example is not the code you've tested.
I fixed the error and ran the following code in eclipse:
package test;
import java.io.Reader;
import java.io.StringReader;
import javax.script.Invocable;
import php.java.script.InvocablePhpScriptEngine;
public class HelloWorld {
public static void main(String[] args) {
String l = "3";
System.setProperty("php.java.bridge.default_log_level", l);
System.setProperty("php.java.bridge.default_log_file", "");
System.setProperty("php.java.bridge.php_exec", "php-cgi");
try {
InvocablePhpScriptEngine engine = new InvocablePhpScriptEngine();
String s = "<?php echo 'HelloWorld!\n'; ?>";
engine.eval(new StringReader(s));
String name = (String)
((Invocable)engine).invokeFunction("java_get_server_name", new Object[]{});
System.out.println("PHP/Java communication port: " + name);
engine.eval((Reader)null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
The result:
PHP/Java communication port: 127.0.0.1:9267
HelloWorld!
> java.lang.NullPointerException
The null pointer exception is because the eval failed. Or eval has never been called.
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2008-09-26 15:43:26
|
Hi,
For example:
>
> jrunscript -classpath JavaBridge.jar -l php-interactive
> > function toString() {return "hello Java, I am PHP";}
> > echo java_closure();
> => hello Java, I am PHP
>
> [to run the above example make sure that JavaBridge.jar and php-script.jar
> is in the current working directory and that jre/lib/ext does not contain
> JavaBridge.jar and php-script.jar -- Java doesn't have a module system,
> please
> see our README section Java Platform Issues for details. Use .NET or Mono
> if you
> don't like how Java works around that problem... ]
>
Removed the files from the jre/lib/ext directory. Ran the script. I get the
prompt. I enter the first line and hit enter. Result is a stack overflow
error traced back to line 89 of the InteractivePhpScriptEngine.java file (in
which the entered script is trimmed and a ';' is added as far as I can tell
by checking the source code):
Exception in thread "main" java.lang.StackOverflowError
at java.lang.String.<init>(String.java:216)
at java.lang.StringBuffer.toString(StringBuffer.java:585)
at
php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:89)
at
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:97)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
at
php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:91)
at
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:97)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
at
php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:91)
at
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
(this goes on for a while)
Looking at the code what is happening (as far as I can see) is that it
attempts an eval call in InteractivePhpScriptEngine:
try {o=((Invocable)this).invokeFunction("javabridge_eval", new
Object[]{script});}catch(NoSuchMethodException ex){/*ignore*/};
For this it calls invokeFunction in InvocablePhpScriptEngine, which calls
invoke(String methodName, Object[] args) in InvocablePhpScriptEngine. This
method attempts if(scriptClosure==null) eval("<?php ?>") in line 97. This
eval call then leads to a repeat of the cycle until at some point it fails
at line 89 of the InteractivePhpScriptEngine with the stackoverlfowexception
since the stack is full. So somehow the evaluation of any input script fails
(including the "<?php ?>) until the stack is full. Any thoughts on what
might be causing this?
===================================================================================================
I also tried your example via Netbeans by adding the jar files directly to
the project (not onto the overall classpath by putting them in the
jre/lib/ext directory).
Your example to which I added a few debug lines using System.out.println:
package test;
>
> import java.io.Reader;
> import java.io.StringReader;
>
> import javax.script.Invocable;
>
> import php.java.script.InvocablePhpScriptEngine;
>
> public class HelloWorld {
>
> public static void main(String[] args) {
>
> String l = "3";
> System.setProperty("php.java.bridge.default_log_level", l);
> System.setProperty("php.java.bridge.default_log_file", "");
> System.setProperty("php.java.bridge.php_exec", "php-cgi");
>
> try {
> InvocablePhpScriptEngine engine = new InvocablePhpScriptEngine();
> String s = "<?php echo 'HelloWorld!\n'; ?>";
> System.out.println("here");
> engine.eval(new StringReader(s));
> System.out.println("here2");
> String name = (String)
> ((Invocable)engine).invokeFunction("java_get_server_name", new Object[]{});
> System.out.println("PHP/Java communication port: " + name);
>
> engine.eval((Reader)null);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
> The result:
>
> PHP/Java communication port: 127.0.0.1:9267
> HelloWorld!
My result:
here
here2
java.lang.NullPointerException
at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:636)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:116)
at
php.java.script.InvocablePhpScriptEngine.invoke(InvocablePhpScriptEngine.java:100)
at
php.java.script.InvocablePhpScriptEngine.invokeFunction(InvocablePhpScriptEngine.java:108)
Here it seems the actual invoke is never reached in method invoke(Object
thiz, String methodName, Object[] args) as it fails while obtaining the
invocation handler through the Proxy class; and thus before calling the
invoke method on the phpscriptprocedure object. My best guess would be that
the 'thiz' object is null and this is why the proxy part fails.
InvokeFunction calls invoke(String methodName, Object[] args), which
contains the part
if(scriptClosure==null) eval("<?php ?>");
try {
return invoke(scriptClosure, methodName, args);
}
This call then invokes invoke(Object thiz, String methodName, Object[]
args), which leads to the null pointer exception at line 116. As you said
already, clearly also here the eval part either fails and returns null (just
like with the jrunscript test I did), or it is never performed.
The question is why. Any thoughts on why this is the case?
Kind regards,
Bart
p.s: thanks a lot for all your patience and efforts to help with this.
|
|
From: <php...@li...> - 2008-09-26 19:22:18
|
Hi,
> the 'thiz' object is null and this is why the proxy
> part fails.
this happens if the script could not call into the Java continuation.
"Invocable" scripts are evaluated in three parts:
part 1 load Java.inc/php_java.dll
part 2 is your script code
part 3 is the call back into Java (if your code did not call into Java)
The full script looks like this:
<?php require("http://<localhost>:dynamicPort/JavaBridge/java/Java.inc")?>
<?php ... your PHP code ... ?>
<?php java_context()->call(java_closure());
When a php_java.dll exists, part#1 will not be called. In this case we assume that your PHP installation already uses the PHP/Java Bridge.
If the asumption is false, and the php_java.dll does not export java_context(), part#3 will fail and Java will not be able to get- and call the PHP continuation.
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2008-10-07 15:14:53
|
Hi,
I don't have php_java.dll.
Could you send me the correct version needed for the bridge?
With that dll in hand, how can I then get my PHP installation to use the
PHP/JavaBridge?
Bart
On Fri, Sep 26, 2008 at 9:22 PM, <
php...@li...> wrote:
> Hi,
>
> > the 'thiz' object is null and this is why the proxy
> > part fails.
>
> this happens if the script could not call into the Java continuation.
>
>
> "Invocable" scripts are evaluated in three parts:
>
> part 1 load Java.inc/php_java.dll
>
> part 2 is your script code
>
> part 3 is the call back into Java (if your code did not call into Java)
>
>
> The full script looks like this:
>
> <?php require("http://<localhost>:dynamicPort/JavaBridge/java/Java.inc")?>
> <?php ... your PHP code ... ?>
> <?php java_context()->call(java_closure());
>
> When a php_java.dll exists, part#1 will not be called. In this case we
> assume that your PHP installation already uses the PHP/Java Bridge.
>
> If the asumption is false, and the php_java.dll does not export
> java_context(), part#3 will fail and Java will not be able to get- and call
> the PHP continuation.
>
>
> Regards,
> Jost Boekemeier
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>
--
The new is always the old. Everything that's old was once new, and
everything that's new will one day be old. The oldest thing of all is the
present, because there's never been anything else but the present. No one
has ever lived in the past, and no one lives in the future, either.
|
|
From: <php...@li...> - 2008-10-07 20:20:26
|
Hi,
> I don't have php_java.dll.
Good!
> Could you send me the correct version needed for the
> bridge?
I don't have it either. -- The dll is only neccessary for PHP 4.
> With that dll in hand, how can I then get my PHP
> installation to use the
> PHP/JavaBridge?
The bridge uses fopen and fread/fwrite to send/receive XML requests to/from the PhpJavaServlet. I am a little bit surprised that this simple mechanism causes problems.
Regards,
Jost Boekemeier
|
|
From: <php...@li...> - 2008-10-07 20:57:24
|
Hi,
so the problem is not having a php_java.dll then, since I don't have it.
What could then the reason by of the errors I get from Netbeans.
To repeat my steps:
1) installed JDK 1.6.0_7 and php 5.2.6.
2) downloaded and unzipped java bridge zip file.
3) ran the test installation.
4) tested the Jrunscript with some examples, works fine.
5) tested the deployment of the war file to apache tomcat, works fine for
the java standalone examples.
6) copied php-script.jar and javabridge.jar to java.ext.dirs.
7) opened netbeans 6.0.1 and created java application with example code from
the documentation/server/test involving an invocable php-engine (Netbeans
settings for PHP is to use the php.exe file for handling php files).
8) ran the code resulting in the error reported in the email below.
Since there is no php_java.dll, what could the issue be that is causing the
problem?
Or, alternatively, am I missing a step here to get this to work?
Regards,
Bart
On Fri, Sep 26, 2008 at 9:22 PM, <
php...@li...> wrote:
> Hi,
>
> > the 'thiz' object is null and this is why the proxy
> > part fails.
>
> this happens if the script could not call into the Java continuation.
>
>
> "Invocable" scripts are evaluated in three parts:
>
> part 1 load Java.inc/php_java.dll
>
> part 2 is your script code
>
> part 3 is the call back into Java (if your code did not call into Java)
>
>
> The full script looks like this:
>
> <?php require("http://<localhost>:dynamicPort/JavaBridge/java/Java.inc")?>
> <?php ... your PHP code ... ?>
> <?php java_context()->call(java_closure());
>
> When a php_java.dll exists, part#1 will not be called. In this case we
> assume that your PHP installation already uses the PHP/Java Bridge.
>
> If the asumption is false, and the php_java.dll does not export
> java_context(), part#3 will fail and Java will not be able to get- and call
> the PHP continuation.
>
>
> Regards,
> Jost Boekemeier
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>
--
The new is always the old. Everything that's old was once new, and
everything that's new will one day be old. The oldest thing of all is the
present, because there's never been anything else but the present. No one
has ever lived in the past, and no one lives in the future, either.
|
|
From: <php...@li...> - 2008-10-08 18:45:51
|
Hi, > 8) ran the code resulting in the error reported in the > email below. we're sorry, but we could not reproduce this problem. Please open a bug report (please use http://sourceforge.net/tracker/?func=add&group_id=117793&atid=679233) and include a piece of test code and the php executable (php-cgi.exe,php5ts.dll) and the JavaBridge.jar and php-script.jar you've used for the test. Please also include the error message. Regards, Jost Boekemeier |
|
From: <php...@li...> - 2008-10-11 19:07:37
|
Hi,
regarding the Netbeans issue. I attempted to solve the issue, but no luck
yet. To just summarize the status:
-ran the war installation part
-copied the java bridge and php-script jar files to the java.ext.dirs.
-the simple code I am trying to run is (without the try/catch):
InvocablePhpScriptEngine engine = new InvocablePhpScriptEngine();
String s = "<?php echo 'HelloWorld!\n'; ?>";
System.out.println("here");
engine.eval(new StringReader(s));
System.out.println("here2");
String name = (String)
((Invocable)engine).invokeFunction("java_get_server_name", new Object[]{});
System.out.println("PHP/Java communication port: " + name);
engine.eval((Reader)null);
-this leads to the reported error of the null pointer exception when
obtaining a handler.
I suspect the problem may lie in setting the properties of the bridge in the
java code. In my code
I set them as follows:
System.setProperty("php.java.bridge.default_log_level", "3");
System.setProperty("php.java.bridge.default_log_file", "");
System.setProperty("php.java.bridge.php_exec", "php-cgi");
Now, I am running this on Windows, where the location of the php-cgi.exe
file is "c:\php\php-cgi.exe" (which is part of the standard php 5.2.6
download together with the php5ts.dll library).
I attempted to set the "php.java.bridge.php_exec" property to this location
(in different variations), but that did not work.
Could you please inform what is the proper way to set these properties (in
order to rule out this potential cause)?
Regards,
Bart
On Wed, Oct 8, 2008 at 8:45 PM, <php...@li...
> wrote:
> Hi,
>
> > 8) ran the code resulting in the error reported in the
> > email below.
>
> we're sorry, but we could not reproduce this problem.
>
>
> Please open a bug report (please use
> http://sourceforge.net/tracker/?func=add&group_id=117793&atid=679233) and
> include a piece of test code and the php executable (php-cgi.exe,php5ts.dll)
> and the JavaBridge.jar and php-script.jar you've used for the test. Please
> also include the error message.
>
>
> Regards,
> Jost Boekemeier
>
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>
--
The new is always the old. Everything that's old was once new, and
everything that's new will one day be old. The oldest thing of all is the
present, because there's never been anything else but the present. No one
has ever lived in the past, and no one lives in the future, either.
|
|
From: <php...@li...> - 2008-10-11 19:20:42
|
Hi,
in follow up to my previous email:
pls disregard. I fixed the problem with another variation of the properties
settings.
Regards,
Bart
On Sat, Oct 11, 2008 at 9:07 PM, Bart Orriens <bar...@gm...>wrote:
>
> Hi,
>
> regarding the Netbeans issue. I attempted to solve the issue, but no luck
> yet. To just summarize the status:
>
> -ran the war installation part
> -copied the java bridge and php-script jar files to the java.ext.dirs.
> -the simple code I am trying to run is (without the try/catch):
>
> InvocablePhpScriptEngine engine = new InvocablePhpScriptEngine();
> String s = "<?php echo 'HelloWorld!\n'; ?>";
> System.out.println("here");
> engine.eval(new StringReader(s));
> System.out.println("here2");
> String name = (String)
> ((Invocable)engine).invokeFunction("java_get_server_name", new Object[]{});
> System.out.println("PHP/Java communication port: " + name);
> engine.eval((Reader)null);
>
> -this leads to the reported error of the null pointer exception when
> obtaining a handler.
>
> I suspect the problem may lie in setting the properties of the bridge in
> the java code. In my code
> I set them as follows:
>
> System.setProperty("php.java.bridge.default_log_level", "3");
> System.setProperty("php.java.bridge.default_log_file", "");
> System.setProperty("php.java.bridge.php_exec", "php-cgi");
>
> Now, I am running this on Windows, where the location of the php-cgi.exe
> file is "c:\php\php-cgi.exe" (which is part of the standard php 5.2.6
> download together with the php5ts.dll library).
>
> I attempted to set the "php.java.bridge.php_exec" property to this location
> (in different variations), but that did not work.
> Could you please inform what is the proper way to set these properties (in
> order to rule out this potential cause)?
>
> Regards,
> Bart
>
>
>
> On Wed, Oct 8, 2008 at 8:45 PM, <
> php...@li...> wrote:
>
>> Hi,
>>
>> > 8) ran the code resulting in the error reported in the
>> > email below.
>>
>> we're sorry, but we could not reproduce this problem.
>>
>>
>> Please open a bug report (please use
>> http://sourceforge.net/tracker/?func=add&group_id=117793&atid=679233) and
>> include a piece of test code and the php executable (php-cgi.exe,php5ts.dll)
>> and the JavaBridge.jar and php-script.jar you've used for the test. Please
>> also include the error message.
>>
>>
>> Regards,
>> Jost Boekemeier
>>
>>
>>
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> php-java-bridge-users mailing list
>> php...@li...
>> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>>
>
>
>
> --
> The new is always the old. Everything that's old was once new, and
> everything that's new will one day be old. The oldest thing of all is the
> present, because there's never been anything else but the present. No one
> has ever lived in the past, and no one lives in the future, either.
>
--
The new is always the old. Everything that's old was once new, and
everything that's new will one day be old. The oldest thing of all is the
present, because there's never been anything else but the present. No one
has ever lived in the past, and no one lives in the future, either.
|
|
From: <php...@li...> - 2008-10-12 16:12:06
|
Hi,
I don't think anyone on the mailing list is interested in this.
Please use our bug tracking system instead. As soon as I see the requested information there, I will respond.
Regards,
Jost Boekemeier
|
|
From: <php...@li...> - 2008-09-26 18:51:54
|
Hi,
> Java 1.6.0.6 with PHP 5.2.2 [..] bridge version 5.2.2
I am sorry, but I cannot reproduce this problem using the above software.
* downloaded PHP/Java Bridge version 5.2.2 and extracted it into c:\
* downloaded Java 1.6.0_06 and installed it
* downloaded PHP 5.2.2 and copied php-cgi.exe and php5ts.dll to
C:\php-java-bridge_5.2.2.4_j2ee\JAVA.STANDALONE
C:\php-java-bridge_5.2.2.4_j2ee\JAVA.STANDALONE>c:\programme\java\jdk1.6.0_06\bin\jrunscript -classpath JavaBridge.jar -l php-interactive
php-interactive> echo 1+2
3
php-interactive> java_autoload();
php-interactive> echo java_lang_System::type()->getProperty("java.version");
1.6.0_06
php-interactive> echo phpversion();
5.2.2
php-interactive> echo php_java_bridge_Util::type()->VERSION;
5.2.2.4
php-interactive>
> Exception in thread "main"
> java.lang.StackOverflowError
php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:89)
The StackOverflowError usually happens when a simple "<?php ?>" call fails.
Please check your PHP installation. Remove it, if necessary, and copy
the php-cgi.exe and php5ts.dll into the local working directory.
Check which extension breaks your system PHP installation. Most likely you use an old Java extension or the Java extension from Zend. Both don't work correctly (at least not with JSR223).
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2008-10-06 09:45:33
|
Hi,
thanks for all the advise. I tried your solution of copying php-cgi.exe and
php5ts.dll to my local working directory. That indeed
solved the issue of the Stackoverflow I got on the command prompt with the
interactive php engine.
I am attempting now to resolve the problems I described using the bridge
from Netbeans. I'll keep you posted on the outcome, though
it may take some time (sometime next week likely) before I can get back to
you.
Thanks already!
Bart
On Fri, Sep 26, 2008 at 8:51 PM, <
php...@li...> wrote:
> Hi,
>
> > Java 1.6.0.6 with PHP 5.2.2 [..] bridge version 5.2.2
>
> I am sorry, but I cannot reproduce this problem using the above software.
>
> * downloaded PHP/Java Bridge version 5.2.2 and extracted it into c:\
>
> * downloaded Java 1.6.0_06 and installed it
>
> * downloaded PHP 5.2.2 and copied php-cgi.exe and php5ts.dll to
> C:\php-java-bridge_5.2.2.4_j2ee\JAVA.STANDALONE
>
>
>
> C:\php-java-bridge_5.2.2.4_j2ee\JAVA.STANDALONE>c:\programme\java\jdk1.6.0_06\bin\jrunscript
> -classpath JavaBridge.jar -l php-interactive
> php-interactive> echo 1+2
> 3
> php-interactive> java_autoload();
>
> php-interactive> echo
> java_lang_System::type()->getProperty("java.version");
> 1.6.0_06
> php-interactive> echo phpversion();
> 5.2.2
> php-interactive> echo php_java_bridge_Util::type()->VERSION;
> 5.2.2.4
> php-interactive>
>
>
>
> > Exception in thread "main"
> > java.lang.StackOverflowError
>
> php.java.script.InteractivePhpScriptEngine.eval(InteractivePhpScriptEngine.java:89)
>
> The StackOverflowError usually happens when a simple "<?php ?>" call fails.
>
> Please check your PHP installation. Remove it, if necessary, and copy
> the php-cgi.exe and php5ts.dll into the local working directory.
>
> Check which extension breaks your system PHP installation. Most likely you
> use an old Java extension or the Java extension from Zend. Both don't work
> correctly (at least not with JSR223).
>
>
> Regards,
> Jost Boekemeier
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>
--
The new is always the old. Everything that's old was once new, and
everything that's new will one day be old. The oldest thing of all is the
present, because there's never been anything else but the present. No one
has ever lived in the past, and no one lives in the future, either.
|