Skip to Content
Technical Articles
Author's profile photo SHOAIB Alam

Testing Groovy Script Locally using Eclipse

This is the continuation of my blog post “Testing Groovy Script Locally using Intellij IDEA”.  In which I tried to explain step-by-step process to set up Intellij IDEA for Testing Groovy script locally. Another popular feature-rich IDE is Eclipse. There are some differences in setting up Eclipse IDE. In this blog post I will go through these steps.

Step 1: Find the correct version of Java, Groovy and Apache Camel

Follow the step 1 in a “Testing Groovy Script Locally using Intellij IDEA” and find out the correct version of Groovy, Java and Camel:

  • Groovy: 2.4.21
  • Java: 1.8.0_311
  • Camel: 2.24.2-sap-23

Step 2: Download and install Eclipse

Before downloading the Eclipse find out the Latest Groovy release and corresponding Eclipse Level from the URL   For example, I am using the eclipse level (2021-12).

Find and download the correct level of Eclipse from You can either download the Eclipse as Installer or as Package. Find out Eclipse 2021-12 (4.22) and download the Installer.

Before installing Eclipse make sure that java 1.8 is installed and configured. It is not the latest version of java but version used by SAP CPI runtime.

I downloaded the Installer and install “Eclipse IDE for Java Developers”. Installation steps are straight forward, and I am not going to go through them.

Step 3: Setup Eclipse and Install Groovy Support

From the following copy the corresponding URL for Groovy release.


Once you have Eclipse installed and running copy the corresponding Groovy URL, then follow these steps:

  1. Go to Help > Install New Software…
  2. Click on Add…
  3. Paste the update site URL appropriate for your version of Eclipse and click Add
  4. Select the new entry in the Work with list of update sites
  5. Expand Main Package and select the Eclipse Groovy Development Tools feature

Click Next and follow the remaining prompts

Step 4: Create Groovy Project and Script

Once Eclipse is installed and restarted create a New Groovy Project:

  • File –> New –> Project –> Groovy Project

Let’s project name is com.groovy.testing. Now create a New Groovy Type under the project:

Let’s name of the Script is GroovyCPITest


Add the following code to the groovy script. It is an auto generated code when you create groovy step in CPI.

import java.util.HashMap;

def Message processData(Message message) {
	   def body = message.getBody();
	   message.setBody(body + "Body is modified");
	   def map = message.getHeaders();
	   def value = map.get("oldHeader");
	   message.setHeader("oldHeader", value + "modified");
	   message.setHeader("newHeader", "newHeader");
	   map = message.getProperties();
	   value = map.get("oldProperty");
	   message.setProperty("oldProperty", value + "modified");
	   message.setProperty("newProperty", "newProperty");
	   return message;



In order to resolve the class you can download the Script API from the following URL:

But this approach only gives you a real bare bone JAR file and it is pretty much useless.

As I explained in Step 5 of my post “Testing Groovy Script Locally using Intellij IDEA” download stack.worker_cf.karaf-6.xx.x.war file. Unzip this file in a directory and it will provide all the required jars. For further details, Ariel Bravo Ayala wrote a blog post which explain how to explore the CPI filesystem.

You need to make the two changes mentioned by Manish Kumar in his comments to make it work.

Step 5: Setup Eclipse for testing groovy code

Now you have all the required jars for developing and testing your groovy code for CPI. Eng Swee Yeoh wrote an article about how to test groovy code in your IDE

Create a new script.groovy file with a script in step 4 using any text editor and save it.  You can use the GroovyCPITest Script Example created above or create a new. Use the code from the above-mentioned blog by Eng Swee Yeoh to test your script.


// Load Groovy Script
GroovyShell shell = new GroovyShell()
def script = shell.parse(new File("script.groovy"))

Message msg = new MessageImpl()
msg.setBody(new String("Hello Groovy World "))
msg.setHeader("oldHeader", "MyGroovyHeader")
msg.setProperty("oldProperty", "MyGroovyProperty")


println("Body:\r\n" + msg.getBody())

def displayMaps = { String mapName, Map map ->
	println mapName
	map.each { key, value -> println( key + " = " + value) }
displayMaps("Headers:", msg.getHeaders())
displayMaps("Properties:", msg.getProperties())

You need to find out all required JAR files to resolve &

I found the following list of jars files from stack.worker_cf.karaf-6.xx.x.war required to run the code.

  • apache.camel.camel-core

I also downloaded and add the following 3 jars to run it successfully:

  • slf4j-api-1.7.2.jar
  • slf4j-simple-1.7.2.jar
  • activation.jar

Now everything set to test your Groovy Code using Eclipse IDE. You can run the test either as a Java Application or via Groovy Console.

Following is the Groovy Console output:


This is a continuation of my previous post in which I tried to explain how to setup Intellij IDE for local development and testing of Groovy Code. Eclipse is another feature rich and popular IDE. In this blog I tried to illustrate how to use Eclipse IDE to development and test Groovy scripts.

There are some differences in setting up Intellij and Eclipse. For example, Eclipse requires additional activation.jar library as compared to Intellij.

Initial setup might seem a little bit lengthy and cumbersome, but it is a one-off activity. Once completed, you can benefit from the productivity boost provided by the usage of an IDE of your choice either Intellij or Eclipse. It will enhance development experience – code inspection and completion, and most importantly testing and debugging.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Eason Ji
      Eason Ji

      The picture is too small, it is not clear, would you please adjust pictures' size?

      Author's profile photo Eurico Borges
      Eurico Borges

      Great article SHOAIB Alam

      I am trying to follow your steps in NEO environment but I'm not managing to see contents of filesystem. I'm stuck in step 4 of this article.  After following Step 5 of your post “Testing Groovy Script Locally using Intellij IDEA” as you suggest, I manage to execute the call to


      but instead of the directory listing I only get a blank screen in my browser. No error is returned, or registered in CPI log,  but also no file list is returned.

      If I try to access directly the path


      in orther to get the stack.worker_cf.karaf-6.xx.x.war file I get an error in browser

      and the message we can see in the iflow logs is

      "Error Details An internal server error occured: /app/webapps@ line 17 in script1.groovy. The MPL ID for the failed message is : AGQLGSSbqs9jdDOnqIzXvq5-pmR0"
      I'm guessing the file system structure might have changed.
      Do you have any suggestion to correct this error or know of any other location that we can use in order to get the stack.worker_cf.karaf-6.xx.x.war file ?
      If not then would you please share this file with me (Google Drive, One drive or similar ...) ?
      Thank you