Contact Us 1-800-596-4880

Upgrading and Migrating Scripting Module to Version 2.1 - Mule 4

Upgrade Anypoint Connector for Scripting module (Scripting module) to version 2.0.0.

Supported Upgrade Paths

From Version To Version

1.1.7

2.0.0

Changes in This Release

This release contains the following changes:

  • Because the Scripting module no longer provides default scripting engines, perform one of the following actions:

    • Use the Configure…​ button to install your desired engines.

    • Specify desired engines in the pom.xml file of your application.

  • For any data stream provided in the payload or variables, a cursor object opens and binds so that you need not open new cursors.
    Any openCursor() provided to the Scripting module closes after the script execution.

Upgrade Prerequisites

Before you perform the upgrade, you must create a backup of your files, data, and configurations in case you need to restore to them.

Upgrade Steps

Follow these steps to perform the upgrade:

  1. In Anypoint Studio, create a Mule project.

  2. In Mule Palette, click Search in Exchange.

  3. In Add Dependencies to Project, enter scripting module in the search field.

  4. In Available modules, select Scripting module and click Add.

  5. Click Finish.

  6. Verify that the mule-scripting-module dependency version is 2.0.0 in the Mule project file.

Studio upgrades the connector version automatically.

Post-Upgrade Steps

After you install the latest version of the connector, add a jsr-223-compliant scripting engine:

  1. In Anypoint Studio, navigate to the Execute tab operation of your application.

  2. Use one of the following two options to install and configure a jsr-223-compliant engine:

    • In the Required Libraries section, click Configure…​ and select one of the following options to search and install the engine:

      • Add recommended libraries
        Install Groovy engine as recommended. This option appears only if you did not previously install Groovy.

      • Use local file
        Browse a local file for the required engine library and install it.

      • Add Maven dependency
        Browse the engine dependency and install it.

    • In the pom.xml file, manually add the engine in both of these sections:

      • <sharedLibraries> tags under the <configuration> section

      • <dependency> tags under the <dependencies> section

Starting with Java 17, execution of JavaScript code requires the GraalVm engine. To use this engine, add the following library dependencies to your pom.xml file :
<sharedLibrary>
    <groupId>org.graalvm.js</groupId>
    <artifactId>js</artifactId>
</sharedLibrary>
<sharedLibrary>
    <groupId>org.graalvm.js</groupId>
    <artifactId>js-scriptengine</artifactId>
</sharedLibrary>
  1. In the General section of the Execute tab, click the refresh button to update the engine values list for the operation.

  2. In Engine, select the installed engine.

Verify the Upgrade

After you install the latest version of the connector, verify the upgrade:

  1. In Studio, verify that there are no errors in the Problems or Console views.

  2. Verify that there are no problems in the project file.

  3. Test the connection to verify that the operations work.

Troubleshooting

  • Engine names inconsistency
    When you see different engine names in the Studio configuration tab and Configuration XML tab, engine names display differently than in previous Scripting module versions. This occurs because the engine company defines and provides an identifier for both the engine and language name, for example:

Engine Name Studio Configuration Configuration XML

Jython

Jython

Python

Groovy

Groovy Scripting Engine

Groovy

Nashorn (JavaScript)

Oracle Nashorn

ECMASCript

  • Jython engine
    When you use a Jython engine that’s not a standalone version in Scripting module v2.0, cause the application to fail. Previous Scripting module versions worked with Jython engines that were not standalone versions. Use jython-standalone version for Scripting module v2.0. For additional information, see Scripting Module XML and Maven Support.

  • Oracle Nashorn engine
    If you see Oracle Nashorn (ECMASCript) engine as an available option to select in the Studio configuration tab without the necessity to install or configure it, this indicates that some versions of JVM (Java Virtual Machine) previously installed and use the engine.

Reverting the Upgrade

If you need to revert to the previous version of Scripting module, go to Anypoint Studio and do the following:

  1. In the project’s pom.xml file, change the mule-scripting-module dependency version 2.0.0 to the previous version, and delete the engine dependency used from the <dependencies> section.

  2. Return to the Execute tab, and in the Engine section, select one of the default engines.

  3. In the Configuration XML tab, confirm the selected engine name also changed.

View on GitHub