NullPointerException in ThreadSafeLocalContextProvider

Hi,

I run a script at a regular interval using jruby-complete-1.6.4.jar as
follows:

System.setProperty(“org.jruby.embed.localvariable.behavior”, “global”);
System.setProperty(“org.jruby.embed.localcontext.scope”, “threadsafe”);
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName(“jruby”);

SimpleScriptContext context = new SimpleScriptContext();
context.setAttribute(“variable 1”, “…”, ScriptContext.ENGINE_SCOPE);
context.setAttribute(“variable 2”, “…”, ScriptContext.ENGINE_SCOPE);
context.setAttribute(“org.jruby.embed.termination”, true,
ScriptContext.ENGINE_SCOPE);
Reader script = …;
engine.eval(script, context);

So the “org.jruby.embed.termination” is set true to do the necessary
cleanup after running the script.
This results in the following exception:


Caused by: java.lang.NullPointerException
at
org.jruby.embed.internal.ThreadSafeLocalContextProvider.getVarMap(ThreadSafeLocalContextProvider.java:65)
at
org.jruby.embed.ScriptingContainer.getVarMap(ScriptingContainer.java:997)
at org.jruby.embed.jsr223.Utils.postEval(Utils.java:126)
at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:134)

If I don’t set the “org.jruby.embed.termination” option the application
goes out of memory after some time.

Any idea what goes wrong?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs