Crash + eXo Platform – sizeOf JCR content command

This guest post was adapted from an original article written in French by Stefan Letzner.

Crash is a tool for connecting to a JVM and using all the libraries it loads to run Groovy scripts, browse the JCR, etc…

This tool can operate in different ways:

  • As a stantalone
  • In web mode, deployed as a web app
  • Directly injected by Spring

In our case, we’re going to use a web version deployed in a Tomcat to get connected to the eXo Platform JCR. Two versions of the web mode exist: one is configured to connect to eXo Platform while the other is more generic.

Getting started with Crash

At first we will see how to connect to Crash once it has been deployed in the eXo Platform Tomcat.

By default, Crash listens to port 2000 for ssh and port 5000 for telnet. These are both available for connecting. In our case, we will connect via ssh, with the root user (password: gtn):

where “localhost” is the name of the server hosting the Tomcat.

We then access the Crash command prompt:

Then, we need to connect to the repository:

And connect to the workspace (here it is: “collaboration”):

From here, we can navigate the JCR and do things with nodes such as creating, deleting and moving them.

Creating a new Crash command

A new command is created via a Groovy script.

In the WAR, in WEB-INF there is a directory named crash/commands. It has two directories for hosting Groovy scripts. The first contains general commands (system) and the second contains JCR commands.

Then we create a Groovy script named “sizeof.groovy” and move it into the JCR directory.

New scripts and changes to existing scripts are hot deployed.

This new command includes the options:

-t (type): filters on “jcr:primaryType”
-l (limit): limits the number of results
-f (outPutFile): the path and name of the file of results

and a mandatory parameter, “jcr:path”, which is the path from where we want to launch the research.

Here is the script code:

Once the script has been deployed, we can use the “help” command to ensure the script is properly available in Crash:

Now, we can easily execute the following command:

In return, we’ll get a table listing the content paths as well as their size, from the largest to the smallest.

Crash is very well documented. You can find all the information you need on

Join the eXo tribe by registering for the community and access tutorials, support, and downloads!

About Stefan Letzner

Stefan moved from web design to development and thus worked on many projects involving very different technologies: C#/WPF, Java/J2EE, JQuery, Groovy, Android…

A developer at Capgemini since 2008, Stefan has worked on different projects, and he is very interested in open source environments. Recently, Stefan has been hosting a blog which regroups code snippets, patterns and tips that are used on projects and that might need to be found quickly. It makes sure the knowledge is not lost.

Be part of the discussion, share your comments