Mantis - Quercus
Viewing Issue Advanced Details
2554 crash always 03-25-08 23:27 04-16-08 10:29
sjdelfab  
nam  
normal  
closed 3.1.5  
fixed  
none    
none 3.1.6  
0002554: Script time out when using Quercus
Get the following exception when executing a PHP script via javax.script interfaces.

com.caucho.quercus.QuercusRuntimeException: script timed out
at com.caucho.quercus.env.Env.checkTimeout(Env.java:764)
at com.caucho.quercus.expr.FunctionExpr.evalImpl(FunctionExpr.java:175)
at com.caucho.quercus.expr.FunctionExpr.eval(FunctionExpr.java:126)
at com.caucho.quercus.program.ExprStatement.execute(ExprStatement.java:64)
at com.caucho.quercus.program.BlockStatement.execute(BlockStatement.java:99)
at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:239)
at com.caucho.quercus.script.QuercusCompiledScript.eval(QuercusCompiledScript.java:88)
at test.psd.workflow.RunPhpScript2.main(RunPhpScript2.java:46)

To test, run

public class RunPhpScript2 {

  private static String scriptStr = "<?php " +
  "function parau() { " +
  " echo \"O vai 'oe ?\n\";" +
  " };" +
  " echo \"Ia ora na\n\";" +
  " parau();" +
  " echo \"A parahi\";" +
  " ?>";
    
    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        Writer stdOut = null;
        try {
            Writer strWriter = new StringWriter();
            stdOut = new PrintWriter(strWriter);
            ScriptEngine phpEngine = new QuercusScriptEngineFactory().getScriptEngine();
            ScriptContext scriptContext = phpEngine.getContext();
            scriptContext.setWriter(stdOut);
            Bindings bindings = phpEngine.createBindings();
            HashMap<String,Object> map = new HashMap<String,Object>();
            //$invoiceId = 1;
            map.put("invoiceId", new Integer(1));
            bindings.putAll(map);
            scriptContext.setBindings(bindings,ScriptContext.ENGINE_SCOPE);
            CompiledScript script = ((Compilable)phpEngine).compile(scriptStr);
            script.eval(scriptContext);
            stdOut.flush();
            System.out.println(strWriter.toString());
        } finally {
            if (stdOut != null) {
                try {
                    stdOut.close();
                } catch (IOException e) {
                    //ignore
                }
            }
        }
    }

}
Similar to issue: http://bugs.caucho.com/bug_view_page.php?bug_id=2067 [^]

java -version =
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)

When running as Ant script:

ant -v -f build-tmp.xml phpTest
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: build-tmp.xml
Detected Java version: 1.5 in: c:\program files\java\jdk1.6.0_02\jre
Detected OS: Windows XP

phpTest:
     [java] Executing 'C:\program files\java\jdk1.6.0_02\jre\bin\java.exe' with arguments:
     [java] '-Xmx1024m'
     [java] '-classpath'
     [java] 'C:\SVN\pbrc\Head\src\classes;C:\SVN\pbrc\Head\dependencies\javalibs\server\quercus.jar;C:\SVN\pbrc\Head\dependencies\javalibs\server
\resin-util.jar;C:\SVN\pbrc\Head\dependencies\javalibs\common\script-api.jar'
     [java] 'test.psd.workflow.RunPhpScript2'
     [java]
     [java] The ' characters around the executable and arguments are
     [java] not part of the command.
     [java] 26/03/2008 17:52:42 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.ApacheModule
     [java] java.lang.NoClassDefFoundError: javax/servlet/ServletRequest
     [java] 26/03/2008 17:52:42 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.MailModule
     [java] java.lang.NoClassDefFoundError: javax/mail/Address
     [java] 26/03/2008 17:52:43 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.QuercusModule
     [java] java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
     [java] 26/03/2008 17:52:43 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.i18n.UnicodeModule
     [java] java.lang.NoClassDefFoundError: javax/mail/MessagingException
     [java] 26/03/2008 17:52:43 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.ApacheModule
     [java] java.lang.NoClassDefFoundError: javax/servlet/ServletRequest
     [java] 26/03/2008 17:52:43 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.MailModule
     [java] java.lang.NoClassDefFoundError: javax/mail/Address
     [java] 26/03/2008 17:52:43 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.QuercusModule
     [java] java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
     [java] 26/03/2008 17:52:43 com.caucho.quercus.Quercus parseServicesModule
     [java] INFO: Failed loading com.caucho.quercus.lib.i18n.UnicodeModule
     [java] java.lang.NoClassDefFoundError: javax/mail/MessagingException
     [java] Exception in thread "main" com.caucho.quercus.QuercusRuntimeException: script timed out

Notes
(0002979)
nam   
04-16-08 10:29   
php/214f

Only affects Compilable.compile scripts.