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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Use of Transient Variable in JavaScript With Camunda External Task
  • Automating IoT With Camunda Platform
  • PWA on iOS, Part 3: Chrome on iPhone Is WebKit Too. How One Engine Sets the Rules for PWAs on iOS
  • PWA on iOS, Part 2: HTTPS, Manifest and Service Worker

Trending

  • Architecture Review Boards for Generative AI: A Framework for Governance, Risk Management, and Responsible Adoption
  • Why Scraping Pipelines Break in Production
  • Choosing a BBD Framework
  • The "Just Read the Code" Myth Is Killing Your AI Workflow

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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.

By 
Alok Singh
·
Sep. 27, 22 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
7.1K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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.

Related

  • Use of Transient Variable in JavaScript With Camunda External Task
  • Automating IoT With Camunda Platform
  • PWA on iOS, Part 3: Chrome on iPhone Is WebKit Too. How One Engine Sets the Rules for PWAs on iOS
  • PWA on iOS, Part 2: HTTPS, Manifest and Service Worker

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook