DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. JavaScript
  4. Comparison and Usage of Javascript Engines in Camunda

Comparison and Usage of Javascript Engines in Camunda

In this article, let’s look at how to use Javascript as a scripting language in Camunda with the introduction of Java 15.

Alok Singh user avatar by
Alok Singh
CORE ·
Sep. 27, 22 · Tutorial
Like (2)
Save
Tweet
Share
4.14K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, let’s look at how to use Javascript as a scripting language in Camunda with the introduction of Java 15, where the Nashorn Javascript Engine is removed from Java.

Pre-requisite

  1. Java 15+
  2. Eclipse IDE – Used in this article to switch between Java versions from demonstration
  3. Camunda 7.16

Background

            Java 8 introduced Nashorn Javascript Engine, and Camunda is using the same to process scripts written in Javascript. With the introduction of Java 15 (supported by Camunda v7.16+), Nashorn Javascript Engine is removed. Camunda v7.16+ now supports GraalVM Javascript as a Javascript engine as well.

            Further, Let’s see how to use Javascript in Camunda v7.16+ (where GraalVM Javascript support is present) with Java 15+ (without Nashorn) and prior to Java 15 (with Nashorn).

Let’s Begin

            This article will use the embedded Camunda engine; if you have not done it before, follow the link to have an embedded Camunda engine application. Change the Camunda and Java versions to 7.16 and Java 8, respectively, to begin with. 

            Change the process.bpmn to have script task and script format as JavaScript as below.

Change the process.bpmn to have script task and script format as JavaScript.

Next, the same BPMN will run with Java 8 and Java 15. Let’s set the eclipse compiler to Java 8.

Java Script with Java version prior to 15 (in this case: Java 8):

Change the eclipse compiler to Java 8.

Change the eclipse compiler to Java 8.

Next, build the project and run it. Login to the cockpit and try to start the process deployed with the script task created earlier. An error will start appearing like below.

An error will start appearing

To resolve this, we need to add the below property in application.yaml.

YAML
 
camunda:
  bpm:
    generic-properties:
      properties:
        scriptEngineNameJavaScript: nashorn


This is how we can run the process having script format as Javascript in Camunda 7.16+ with Java 14 and below.

Next, will see how to run the same process model if using Java 15 and above.

Java Script with Java version 15 and above (in this case: Java 17):

Change the eclipse compiler settings again to Java 17 (or any version >= 15).

Change the eclipse compiler settings again to Java 17 (or any version >= 15).

Remove the below-added property from the application.yaml as it's not relevant now (Nashorn Javascript engine is not present in Java 15+).

YAML
 
camunda:
  bpm:
    generic-properties:
      properties:
        scriptEngineNameJavaScript: nashorn


Build and run the application and start the process using the cockpit. Again, the below error will start appearing as Camunda is unable to find the Javascript engine.

Error will start appearing as Camunda is unable to find the Javascript engine.

To resolve this, need to add the below 2 dependencies’ in pom.xml as Camunda 7.16 supports GraalVM Javascript as a Javascript engine.

XML
 
<!-- GraalVM JavaScript Engine -->
	<dependency>
	  <groupId>org.graalvm.js</groupId>
	  <artifactId>js</artifactId>
	  <version>21.3.3</version>
	</dependency>
<!-- GraalVM JavaScript ScriptEngine -->
	<dependency>
	  <groupId>org.graalvm.js</groupId>
	  <artifactId>js-scriptengine</artifactId>
	  <version>21.3.3</version>
	</dependency>


Build and run the application and start the process using the cockpit. And it runs successfully this time.

The point to note here is both GraalVM dependencies must have the same version.

Hope this helps.

Camunda Engine JavaScript

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How Chat GPT-3 Changed the Life of Young DevOps Engineers
  • Fixing Bottlenecks in Your Microservices App Flows
  • A Beginner's Guide to Infrastructure as Code
  • Create a CLI Chatbot With the ChatGPT API and Node.js

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: