0

Trying to use quartz 1.8.3 to execute Java code as a script. I'm using the BSF language jars packaged from an Apache BSF 3.1 build. The JVM version is 1.6.0_29.

When it tries to evaluate the script I get:

java.lang.NoSuchMethodError: javax.tools.JavaCompiler.getTask(Ljava/io/Writer;Ljavax/tools/JavaFileManager;Ljavax/tools/DiagnosticListener;Lnet/sourceforge/retroweaver/runtime/java/lang/Iterable;Lnet/sourceforge/retroweaver/runtime/java/lang/Iterable;Lnet/sourceforge/retroweaver/runtime/java/lang/Iterable;)Ljavax/tools/JavaCompiler$CompilationTask;
    at com.sun.script.java.JavaCompiler.compile(JavaCompiler.java:105)
    at com.sun.script.java.JavaScriptEngine.parse(JavaScriptEngine.java:114)
    at com.sun.script.java.JavaScriptEngine.eval(JavaScriptEngine.java:81)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
    at foo.quartzutils.ScriptJob.evalScript(ScriptJob.java:106)
    at foo.quartzutils.ScriptJob.execute(ScriptJob.java:54)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)

I'm at a loss to determine what could possibly be missing.

UPDATE: To make this even more difficult to track down, this is intermittent. If I schedule the job to run once an hour it might fail three times with that exception, work two, then fail again after that.

user2458080
  • 989
  • 8
  • 17
  • possible duplicate of [How to set classpath when I use javax.tools.JavaCompiler compile the source?](http://stackoverflow.com/questions/1563909/how-to-set-classpath-when-i-use-javax-tools-javacompiler-compile-the-source) – bigGuy Oct 09 '14 at 20:26
  • @bigGuy Not a dupe. That question asks how to use that API, this one it can't find that API. – JasonMArcher Oct 09 '14 at 20:55

1 Answers1

0

Apache Commons BSF is no longer consistent in Java6+

Apache BSF 3.x includes an implementation of JSR-223 (javax.script) and runs on Java 1.4 and Java 1.5. (Java 1.6 includes javax.script as standard.) Note that although the implementation follows the JSR-223 specification, it has not been tested against the JSR-223 TCK. Apache BSF 3.x can therefore not strictly be described as a compatible implementation of JSR-223, however it is believed to be complete.

Quote from Apache website

Kraiss
  • 919
  • 7
  • 22
  • I'm not using the BSF API. I'm using the javax.script from Java 1.6. I did use the machinery in BSF 3.1 to download and assemble a jar full of 3rd party scripting engines. – user2458080 Oct 13 '14 at 17:37