I am trying to call a simple php function in java (see below) and i get the error shown. Any suggestions
package test;
import java.io.IOException;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class cli {
/**
* @param args
* @throws IOException
* @throws ScriptException
*/
public static void main (String[] args) throws IOException, ScriptException {
String l = "5";
System.setProperty ("php.java.bridge.default_log_level", l);
System.setProperty ("php.java.bridge.default_log_file", "");
System.setProperty ("php.java.bridge.php_exec", "/usr/local/php5/bin/php");
ScriptEngine eng = (new ScriptEngineManager ()).getEngineByName ("php-interactive");
System.out.println (eng.eval ("$a=122"));
System.out.println (eng.eval ("$a=$a+1;"));
System.out.println (eng.eval ("echo $a;"));
eng.eval ((String)null);
}
}
=============================================================
see the error
=============================================================
Aug 01 08:17:51 JavaBridge DEBUG: contextfactory: new context: 1@ for web context, # of contexts: 1
Aug 01 08:17:51 JavaBridge DEBUG: created new bridge: php.java.bridge.JavaBridge@706da8
Aug 01 08:17:51 JavaBridge DEBUG: Using php binary: [/usr/local/php5/bin/php]
Aug 01 08:17:51 JavaBridge DEBUG: Started [/usr/local/php5/bin/php, -d, allow_url_include=On]
Aug 01 08:17:51 JavaBridge DEBUG: Socket connection accepted
Aug 01 08:17:51 JavaBridge DEBUG: Starting HTTP server thread from thread pool
Aug 01 08:17:51 JavaBridge DEBUG: 706da8@73eca6 --> <I v="0" m="getContext" p="I" i="1baa7fc" >
Aug 01 08:17:51 JavaBridge DEBUG: 706da8@73eca6 --> </I>
Aug 01 08:17:51 JavaBridge DEBUG:
Invoking [Object 7368104 - Class: php.java.bridge.JavaBridge:ID4712040:LOADER-ID3343727].getContext();
Aug 01 08:17:51 JavaBridge DEBUG:
Result [Object 1253877 - Class: php.java.script.PhpScriptContext:ID1729816:LOADER-ID3343727]
Aug 01 08:17:51 JavaBridge DEBUG: 706da8@73eca6 <-- <O v="1" p="O" i="1baa7fc"/>
Aug 01 08:17:51 JavaBridge DEBUG: 706da8@73eca6 re-directing to port# Pipe:/var/tmp//.php_java_bridgeo2Yypi/php_rz2B0f
Aug 01 08:17:51 JavaBridge DEBUG: 706da8@73eca6 waiting for context: 1@
Aug 01 08:17:51 JavaBridge DEBUG: end (thread returned to pool): Thread[JavaBridgeHttpServerThreadPool#1,5,JavaBridgeHttpServerThreadPool#1]
Aug 01 08:17:51 JavaBridge DEBUG: starting a new ContextRunner php.java.bridge.http.ContextRunner@1bd9c9
Aug 01 08:17:51 JavaBridge ERROR: An exception occured: java.io.IOException: Protocol violation
java.io.IOException: Protocol violation
at php.java.bridge.http.ContextRunner.init(ContextRunner.java:116)
at php.java.bridge.http.ContextRunner.run(ContextRunner.java:139)
at php.java.bridge.BaseThreadPool$Delegate.run(BaseThreadPool.java:58)
Aug 01 08:17:51 JavaBridge DEBUG: end (thread returned to pool): Thread[JavaBridgeContextRunner#1,5,JavaBridgeContextRunner#1]
Exception in thread "main" java.lang.StackOverflowError
Java Result: 1
any help will be appreciated
|