• Icon: Feature Request Feature Request
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.16.0, 7.16.0-alpha3
    • None
    • engine

      User Story (Required on creation):

      • As I user, I want to run the platform with Java 15.

      Functional Requirements (Required before implementation):

      • The engine works with Java 15.
      • The platform (and camunda-spin) is tested against Java 15. (TODO: update INFRA-1548 ticket)
      • A migration guide exists for switching to GraalVM JS from Nashorn (which is not part of the JDK from version 15) for JavaScript script tasks.

      Technical Requirements (Required before implementation):

      Tests containing JavaScript tasks
      • Create profile with GraalVM JS dependencies and compatibility mode properties to be used in the jdk 15 jobs. See list of tests here.
      • Reopen OB-13 or create a new one to add the UPL licenses to the Stop&Go list.
      Invoice example
      • Migrate the scripts to delegates
      Distros
      • Include Graaljs and its dependencies so that users do not have to add the modules themselves (triple-check that this is okay from the license side )
      • Decide what we do for embedded engine/Spring Boot setup (migration guide vs having a dependency in the engine)
      Documentation
      • Determine the best approach for how users can configure GraalVM with Nashorn compatbility mode
        • Option 1 (preferred based on spike):
          1. Users add system parameters to application startup if they want Nashorn compatbility mode
        • Option 2:
          1. Camunda provides a process engine plugin that does the configuration on the script engine level (during the spike, we were not able to configure this correctly this way)
      • Create migration guide for the supported distros and different setups (embedded/shared engine) so the users can easily locate which sections are relevant to them during migration
        • Explain how to enable Nashorn compatibility mode
        • Add section for potential differences between the two script engines (see comment for details). Add disclaimer that more differences might be present and it’s recommended to users to test additionally their scripts before/during the migration
        • Add reference to the GraalVM JS migration guide for further details
        • Mention the GraalVM JS dependencies to https://docs.camunda.org/manual/develop/introduction/third-party-libraries/#process-engine
      • So far we don't have so much documentation on script engine usage. Document how to add/use script engines with some examples, including GraalVM JS. Also considering users who create JavaScript script tasks from now on (without Nashorn compatibility mode).
      Other examples using JavaScript in script tasks
      • We can consider switching to Groovy scripts or write down that the example is not supported for JDK 15. See list of examples here.

      Limitations of Scope (Optional):

      Hints (Optional):

        This is the controller panel for Smart Panels app

            [CAM-12103] Support Java 15

            Tobias Metzke-Bernstein added a comment - - edited

            Hi robert.emsbach, yes. I adjusted the following statement to clear that up a bit hopefully

            We will ship GraalVM JS with the distros, it is used by default for languages "javascript" and "ecmascript".

            It now says

            We will ship GraalVM JS with the distros, it is used by default for languages "javascript" and "ecmascript", regardless of the JDK used to run the distro.

            Tobias Metzke-Bernstein added a comment - - edited Hi robert.emsbach , yes. I adjusted the following statement to clear that up a bit hopefully We will ship GraalVM JS with the distros, it is used by default for languages "javascript" and "ecmascript". It now says We will ship GraalVM JS with the distros, it is used by default for languages "javascript" and "ecmascript", regardless of the JDK used to run the distro .

            Jochen Ulrich added a comment - - edited

            I think it might be interesting to also check if the loading of script files from the classpath still works.

            So something like

            load( "classpath:globalScript.js" )
            

            and maybe also

            import { foo } from "classpath:globalModule.mjs"
            

            Issue #2147 sounds like it is not supported out of the box by GraalJS but possible to implement (see this comment)

            Jochen Ulrich added a comment - - edited I think it might be interesting to also check if the loading of script files from the classpath still works. So something like load( "classpath:globalScript.js" ) and maybe also import { foo } from "classpath:globalModule.mjs" Issue #2147 sounds like it is not supported out of the box by GraalJS but possible to implement (see this comment )

            Thank you, julrich_bee360, that is a good hint. I will evaluate that in the course of investigating Graal.js support

            Tobias Metzke-Bernstein added a comment - Thank you, julrich_bee360 , that is a good hint. I will evaluate that in the course of investigating Graal.js support

            Note for everyone: load( "classpath:..." ) will not work out of the box anymore with GraalJS.
            See this discussion.

            Jochen Ulrich added a comment - Note for everyone: load( "classpath:..." ) will not work out of the box anymore with GraalJS. See this discussion .

            Reading through the discussion it is still not clear to me how loading external scripts will be supported. Will it be required to set a flag or will a currently not existing custom implementation be required? In any case or only if the external script should be loaded from classpath? What about a URL? It would be great to have the different supported use cases and required configuration or customization documented.

            Robert Emsbach added a comment - Reading through the discussion it is still not clear to me how loading external scripts will be supported. Will it be required to set a flag or will a currently not existing custom implementation be required? In any case or only if the external script should be loaded from classpath? What about a URL? It would be great to have the different supported use cases and required configuration or customization documented.

            Tobias Metzke-Bernstein added a comment - - edited

            Hi Robert,

            thanks for verbalizing your concerns. I totally agree that it will be vital to have proper documentation for this. We will add documentation with CAM-13518 and I would actually like to include a couple more reviewers than usual, including you if you're OK with that? I plan to have documentation finished by the end of next week at the latest.

            A brief summary regarding your questions:

            • Loading scripts via load(...) in GraalJS is enabled by default for Strings and JS Object containing script as String, see GraalJS documentation
            • Loading external resources from the FileSystem via load(...) in GraalJS is disabled by default and can be enabled via engine configuration flag
            • Loading external resources from URLs and classpath via load(...) in GraalJS is disabled by default and cannot be enabled via engine configuration. This can be enabled via GraalJS-specific environment variables. This could also be provided by an engine plugin if this is interesting enough for a broader user base.

            I hope that clears up some things.

            Best,
            Tobias

            Tobias Metzke-Bernstein added a comment - - edited Hi Robert, thanks for verbalizing your concerns. I totally agree that it will be vital to have proper documentation for this. We will add documentation with CAM-13518 and I would actually like to include a couple more reviewers than usual, including you if you're OK with that? I plan to have documentation finished by the end of next week at the latest. A brief summary regarding your questions: Loading scripts via load(...) in GraalJS is enabled by default for Strings and JS Object containing script as String, see GraalJS documentation Loading external resources from the FileSystem via load(...) in GraalJS is disabled by default and can be enabled via engine configuration flag Loading external resources from URLs and classpath via load(...) in GraalJS is disabled by default and cannot be enabled via engine configuration. This can be enabled via GraalJS-specific environment variables. This could also be provided by an engine plugin if this is interesting enough for a broader user base. I hope that clears up some things. Best, Tobias

            GraalJS supports loading resources by URL [...]

            But according to the GraalJS documentation this is only enabled if the

            [...] js.load-from-url option is set to true

            So I had a look at the GraalJS source code to find out how this is enabled programatically to verify if this would be enabled by the engine configuration flag in Camunda. And while digging in the code, I found the option load-from-classpath which seems to enable loading files from the classpath (see sourceFromResourceURL()).

            So if the loading from URL could be enabled in Camunda (I don't know how this is done, yet), then I guess it would be equally simple to enable loading from classpath as well.

            Jochen Ulrich added a comment - GraalJS supports loading resources by URL [...] But according to the GraalJS documentation this is only enabled if the [...] js.load-from-url option is set to true So I had a look at the GraalJS source code to find out how this is enabled programatically to verify if this would be enabled by the engine configuration flag in Camunda. And while digging in the code, I found the option load-from-classpath which seems to enable loading files from the classpath (see sourceFromResourceURL() ). So if the loading from URL could be enabled in Camunda (I don't know how this is done, yet), then I guess it would be equally simple to enable loading from classpath as well.

            Hi Jochen,

            thanks for digging into the code of GraalJS and for that pointer.

            How does configuration for GraalJS work in Camunda?
            We are working with the ScriptEngine interface of GraalJS as we do for all other script engine implementations we support. Therefore, we are bound to what is described over here. We can use the six options mentioned there for configuration (the options starting with "polyglot.js"). Now, the options you are mentioning for URL and classpath resource loading can actually not be set by us in that way, GraalJS simply does not offer this to be done with the ScriptEngine interface.

            How can I enable those options?
            You have two options:

            1. As the description above mentions, you can set those options via environment variables (e.g. as "-D" parameters when starting the JVM).
            2. You can enable Nashorn compatibility mode which allows to do resource loading via URL and classpath as well as far as I got the code.

            Usually, you would have to enable Nashorn compatibility mode via environment variable as well. However, thanks to your digging, I just discovered that this should also be available for us via ScriptEngine interface to be set - despite not being documented. So I will most probably add an engine configuration option to enable Nashorn compatibility mode as well.

            I hope that clarifies your questions.

            Tobias Metzke-Bernstein added a comment - Hi Jochen, thanks for digging into the code of GraalJS and for that pointer. How does configuration for GraalJS work in Camunda? We are working with the ScriptEngine interface of GraalJS as we do for all other script engine implementations we support. Therefore, we are bound to what is described over here . We can use the six options mentioned there for configuration (the options starting with "polyglot.js"). Now, the options you are mentioning for URL and classpath resource loading can actually not be set by us in that way, GraalJS simply does not offer this to be done with the ScriptEngine interface. How can I enable those options? You have two options: As the description above mentions, you can set those options via environment variables (e.g. as "-D" parameters when starting the JVM). You can enable Nashorn compatibility mode which allows to do resource loading via URL and classpath as well as far as I got the code. Usually, you would have to enable Nashorn compatibility mode via environment variable as well. However, thanks to your digging, I just discovered that this should also be available for us via ScriptEngine interface to be set - despite not being documented. So I will most probably add an engine configuration option to enable Nashorn compatibility mode as well. I hope that clarifies your questions.

            Jochen Ulrich added a comment - - edited

            As the description above mentions, you can set those options via environment variables (e.g. as "-D" parameters when starting the JVM).

            Indeed! That's very good news! Thanks Tobias!
            So GraalJS enables loading files using classpath:... URLs when setting -Dpolyglot.js.load-from-classpath=true and loading files from HTTP URLs when setting -Dpolyglot.js.load-from-url=true.

            Just note that these options seem to still be considered experimental in latest GraalVM version (21.1.0).
            At least, when using the explicit command line options on the JS interpreter (--js.load-from-classpath and --js.load-from-url), it gives the error:

            ERROR: Option '--js.load-from-classpath=true' is experimental and must be enabled via '--experimental-options'
            Do not use experimental options in production environments.
            

            However, using the environment variables (-Dpolyglot.js.load-from-classpath=true and -Dpolyglot.js.load-from-url=true) does not raise this error.
            But anyway, this is a GraalJS problem.

            Jochen Ulrich added a comment - - edited As the description above mentions, you can set those options via environment variables (e.g. as "-D" parameters when starting the JVM). Indeed! That's very good news! Thanks Tobias! So GraalJS enables loading files using classpath:... URLs when setting -Dpolyglot.js.load-from-classpath=true and loading files from HTTP URLs when setting -Dpolyglot.js.load-from-url=true . Just note that these options seem to still be considered experimental in latest GraalVM version (21.1.0). At least, when using the explicit command line options on the JS interpreter ( --js.load-from-classpath and --js.load-from-url ), it gives the error: ERROR: Option '--js.load-from-classpath=true' is experimental and must be enabled via '--experimental-options' Do not use experimental options in production environments. However, using the environment variables ( -Dpolyglot.js.load-from-classpath=true and -Dpolyglot.js.load-from-url=true ) does not raise this error. But anyway, this is a GraalJS problem.

            Thanks for giving that a try, Jochen.
            Regarding experimental options, as far as I remember those are enabled by default when using the ScriptEngine interface like we do.

            Tobias Metzke-Bernstein added a comment - Thanks for giving that a try, Jochen. Regarding experimental options, as far as I remember those are enabled by default when using the ScriptEngine interface like we do.

              hariharan.parasuraman Hariharan Parasuraman
              thorben.lindhauer Thorben Lindhauer
              Tobias Metzke-Bernstein Tobias Metzke-Bernstein
              Nikola Koevski Nikola Koevski
              Hariharan Parasuraman Hariharan Parasuraman
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: