#186 new
Shaun Elliott

problem loading script from Rhino

Reported by Shaun Elliott | February 24th, 2011 @ 09:43 PM

The following code yields the following error, I'm not sure if it is Rhino or the envjs script (other scripts work fine).

Context cx = Context.enter();

Scriptable scope = cx.initStandardObjects( null );

String scriptText = "";
scriptText += "var manager = new Packages.javax.script.ScriptEngineManager(); ";
scriptText += "var engine = manager.getEngineByName( \"js\" ); ";

String scriptFile = "/temp/env.rhino.1.2.js";
scriptText += "var eval = engine.eval( new Packages.java.io.FileReader( new Packages.java.io.File( \"" + scriptFile + "\" ) ) ) ";

cx.evaluateString( scope, scriptText, "script", 1, null );

Exception in thread "main" org.mozilla.javascript.WrappedException: Wrapped javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing : after property id (#2121) in at line number 2121 (script#1)

at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:183)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.ScriptRuntime.callSpecial(ScriptRuntime.java:2350)
at org.mozilla.javascript.optimizer.OptRuntime.callSpecial(OptRuntime.java:165)
at org.mozilla.javascript.gen.c1._c0(script:1)
at org.mozilla.javascript.gen.c1.call(script)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
at org.mozilla.javascript.gen.c1.call(script)
at org.mozilla.javascript.gen.c1.exec(script)
at org.mozilla.javascript.Context.evaluateString(Context.java:1104)
at com.test.RhinoTest.main(RhinoTest.java:46)

Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing : after property id (#2121) in at line number 2121

at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
... 11 more

When I load the file in the Rhino console it works just fine.

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

a javascript browser environment

People watching this ticket