user1594977
user1594977

Reputation: 3

Grails app on Cloudfoundry: RhinoScriptEngineFactory not found

In my grails application, I needed to execute some javascript (not JSON) fetched from a remote server:

new javax.script.ScriptEngineManager().getEngineByName("javascript")

But got the error: RhinoScriptEngineFactory not found.

I would assumed that RhinoScriptEngineFactory (JSR 223) is included in JDK/JRE. Am I wrong? Does anybody knows the proper way to add Javascript support to a Cloudfoundry application?

Upvotes: 0

Views: 204

Answers (1)

Dan Higham
Dan Higham

Reputation: 3984

it should work if you stage the application using the java7 runtime flag, e.g

vmc push grails-hello --path=target/hello-world-0.1.war --runtime=java7

You can see an example running at http://grails-hello.cloudfoundry.com/hello/index with the following code in the controller;

package hello.world
import javax.script.ScriptEngine;

class HelloController 
{
  def index() 
  { 
      ScriptEngine engine = new javax.script.ScriptEngineManager().getEngineByName("javascript");
      render "hello world (" + engine.toString() + ")";
  }
}

Upvotes: 2

Related Questions