Bogdan had added preliminary, yet powerful, support for scripting in Nuxeo Runtime, before leaving for well deserved vacations. This makes scripting available from all Nuxeo’s platform. Thanks to this new feature, you can easily uses scripts from your custom components. This can be very useful for a lot of use cases, like, dynamic rules (scripting language as DSLs), easily modifiable behaviours, light and powerful configuration / customization, etc. Scripts have access to the whole API thanks to Java scripting integration (JSR-223).

Moreover, scripts can also be run remotely thanks to the Nuxeo Runtime command line. This allow you to create a script on your administration machine, launch it on the remote platform and get the result back. It makes scripting a killer-feature for administration scripts (ex: expire content, bulk content modification, bulk refactoring of the content repository layout, etc.).

Last, but not least, we are working on a interactive shell (using Python or Groovy) to interact with Nuxeo’s platform.

Here is a quote a Bogdan’s mail to get more details:

Hi all,

I’ve just integrated scripting support through JSR 223 in nuxeo.
This was integrated as a new project nuxeo-runtime-scripting which is in svn but it is was not yet
added in the nuxeo.ear build (neither in runtime svn module)

For now only these scripting engine were integrated:

  1. jexl

  2. jruby

  3. groovy

  4. jython

  5. groovy

  6. js (rynho)

If needed I will add more later (like php for example).
You can run scripts in nuxeo in 3 different ways:

  1. Put the script inside the nuxeo.ear/script directory (you should define this directory through a runtime var.)
    Then from the java code you can do:


    where my_script.js is the script path relative to the script directory

    Or you can use the JSR 322 API:

     ScriptEngineManager factory = new ScriptEngineManager();
    ScriptEngine engine = factory.getEngineByName("js");

  2. Let the script inside your .jar and registered it under using name as a script component. The you can run the script as follow:


    This method is caching the compiled script so it is only supported for languages that support compilation. (actually all the engines that comes in nuxeo)

  3. Run a script from remote :)

    This can be used for debug, testing or administration. You write a script locally then you run it against a remote Nuxeo EP server.
    The script will be send to the server and executed on the server then the server will return the result (including STDOUT and STDERR) to the client.

    For security reason this feature can be disabled using a runtime property on the server.

    Here is an example on how you can run a remote script:

       ScriptingClient client = new ScriptingClient("localhost", 62474);
    URL src = RemoteTest.class.getClassLoader().getResource("test.js");
    RemoteScript script = client.loadScript(src);

    For the following js script:

    runtime = Framework.getRuntime();
    name = runtime.getName();
    version = runtime.getVersion();
    desc = runtime.getDescription();
    println("Remote runtime: "+name+" v."+version);
    println("Registered components:");
    regs = runtime.getComponentManager().getRegistrations();
    for (var i=0, size=regs.size(); i<size; i++){

    The following will be printed on the STDOUT of the client:

      Remote runtime: OSGi NXRuntime v.1.4.0
    OSGi NXRuntime version 1.4.0
    Registered components:

So, this new feature can be used to write pure script based Nuxeo components.
Also in future I will try to configure tomcat to be able to run scripts inside servlets.
This means to be able to write we pages in php or other supported language for Nuxeo EP ;-)


I think this open a wide range of new possibilities and ease of use for the Nuxeo Platform to allow you create innovative and powerful ECM applications (and not only, actually, since Nuxeo Runtime can be use to create any extensible application on the Java Platform).

Stay Tuned!


(Post originally written by Eric Barroca on the old Nuxeo blogs.)