Hello, I apologize for sending this twice. It appears the listserv didn't like my attachment. I'm now including the source below.
I'm having some trouble using BSF to execute Javascript code. I'm guessing that it has something to do with the fact that I'm upgrading from old versions (not sure which ones) of BSF and Rhino. I'm able to execute the Javascript directly in Rhino, but I can't get it working with BSF. It seems to be failing in BSF and not even getting into Rhino code. I've attached the source of a sample Java class that I've been working with to debug the problem. I've also included the output I'm seeing below. Any suggestions would be a huge help. Thanks! $ java BSFTest testfoo BSF Javascript call failed: JavaScript Error: Internal Error: java.lang.NullPointerException: java.lang.NullPointerException at java.util.Hashtable.get(Unknown Source) at org.apache.bsf.engines.javascript.RhinoEngineDebugger.loadDocumentNotify(RhinoEngineDebugger.java:158) at org.apache.bsf.engines.javascript.JavaScriptEngine.eval(JavaScriptEngine.java:219) at org.apache.bsf.util.BSFEngineImpl.exec(BSFEngineImpl.java:224) at org.apache.bsf.BSFManager$6.run(BSFManager.java:482) at java.security.AccessController.doPrivileged(Native Method) at org.apache.bsf.BSFManager.exec(BSFManager.java:480) at BSFTest.main(BSFTest.java:21) This is a test! testing: testfoo BSFTest.java: import org.apache.bsf.*; import org.mozilla.javascript.*; public class BSFTest { public static void main(String[] args) { String script = "function test(foo)\n" + "{\n" + " java.lang.System.err.println(\"This is a test!\");\n" + " java.lang.System.err.println(\"testing: \" + foo);\n" + " return 42;\n" + "}"; try { // let's first try using BSF! BSFManager manager = new BSFManager(); manager.exec("javascript", null, -1, -1, script); BSFEngine engine = manager.loadScriptingEngine("javascript"); engine.call("", "test", args); } catch ( Throwable t ) { System.err.println("BSF Javascript call failed: "); t.printStackTrace(); } Context cx = Context.enter(); try { // now let's try using Rhino directly! Scriptable scope = cx.initStandardObjects(null); String s = script + " test(\"" + args[0] + "\")"; Object result = cx.evaluateString(scope, s, "<cmd>", 1, null); System.err.println("result: " + cx.toString(result)); } catch ( Throwable t ) { System.err.println("Rhino Javascript call failed: "); t.printStackTrace(); } finally { Context.exit(); } } } (Embedded image moved to file: pic24578.jpg) Will Taylor Advisory IT Specialist IBM Corporation (802)769-1417 [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]