|
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
|