Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-2857

Cannot reference process application provided classes inside a Groovy Script

    • Icon: Bug Report Bug Report
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.4.0, 7.3.3, 7.2.7, 7.4.0-alpha2
    • None
    • engine
    • None

      Reproduce steps:
      Simple Servlet or EJB process application bundled as WAR file with a dependent JAR bundled in the WAR with the application (maven-managed dependencies). JavaDelegate can refer to classes in bundled JAR but groovy script task can not find classes in bundled JAR.

      Problem:

      Script task throws exception as it can not find referenced class in dependent JAR

      Expected behavior:

      Script task should be able to refer to classes in dependent library JAR, as the JavaDelegate does

      Hints (optional):
      I began this exploration on the camunda-bpm-users google group and have had several exchanges with Daniel Meyer already. Link here: https://groups.google.com/forum/#!topic/camunda-bpm-users/TrZas5rtRco

      Two workarounds for this issue are to either put the dependent JAR in the lib/ext directory of my WAS app server, or to explicitly load the required class from my groovy script. Neither of these solutions is ideal and Daniel suggested filing a bug report

        This is the controller panel for Smart Panels app

            [CAM-2857] Cannot reference process application provided classes inside a Groovy Script

            Sebastian Menski added a comment - - edited

            Hi Bryan,

            Thanks for pointing out this issue. We are currently not aware of a way to fix this issue of the groovy script engine or if we can actually even fix this on our side.

            I want to ask you how important this issue is for you?

            Cheers,
            Sebastian

            Sebastian Menski added a comment - - edited Hi Bryan, Thanks for pointing out this issue. We are currently not aware of a way to fix this issue of the groovy script engine or if we can actually even fix this on our side. I want to ask you how important this issue is for you? Cheers, Sebastian

            Bryan Evans added a comment -

            Hi Sebastian

            This issue is not critical for me. It was critical to have my library application-scoped as opposed to globally shared in lib/ext in my application server, but loading the class explicitly from my groovy script is an acceptable workaround.

            When I execute the process in an embedded-engine scenario, the groovy script is able to find the required class so it seems that the groovy engine does not have access to the application context when run in a shared-engine scenario.

            Anyhow, I just created this ticket at Daniel's suggestion so the issue can be tracked. It is not critical.
            Thank you.

            Bryan Evans added a comment - Hi Sebastian This issue is not critical for me. It was critical to have my library application-scoped as opposed to globally shared in lib/ext in my application server, but loading the class explicitly from my groovy script is an acceptable workaround. When I execute the process in an embedded-engine scenario, the groovy script is able to find the required class so it seems that the groovy engine does not have access to the application context when run in a shared-engine scenario. Anyhow, I just created this ticket at Daniel's suggestion so the issue can be tracked. It is not critical. Thank you.

            Matthijs added a comment -

            Hi Bryan,

            Thanks for your response.

            I have converted this SUPPORT- issue into a CAM- issue for tracking reasons.

            Do let us know if anything changes regarding the urgency.

            Please don't hesitate to contact us in case you have any further questions or remarks.

            Thank you and best regards,

            Mat

            Matthijs added a comment - Hi Bryan, Thanks for your response. I have converted this SUPPORT- issue into a CAM- issue for tracking reasons. Do let us know if anything changes regarding the urgency. Please don't hesitate to contact us in case you have any further questions or remarks. Thank you and best regards, Mat

            Nibin Varghese added a comment - - edited

            Created two eclipse based maven-projects to replicate the bug. I was not able to identify the bug. I tried running this test-application in tomcat instance with shared process engine. The script task was able to import the class from jar (in the war file) and instantiate it.

            let me know if there is something I am missing.

            Nibin Varghese added a comment - - edited Created two eclipse based maven-projects to replicate the bug. I was not able to identify the bug. I tried running this test-application in tomcat instance with shared process engine. The script task was able to import the class from jar (in the war file) and instantiate it. let me know if there is something I am missing.

            Bryan Evans added a comment -

            Hi Nibin

            When I originally started the discussion on this behaviour, I outlined my problem environment as being Websphere Application Server but I don't think it is made clear in this issue. I suspect that your test on tomcat vs. WAS is the reason you did not experience the behaviour that I reported.
            Cheers.

            Bryan

            Bryan Evans added a comment - Hi Nibin When I originally started the discussion on this behaviour, I outlined my problem environment as being Websphere Application Server but I don't think it is made clear in this issue. I suspect that your test on tomcat vs. WAS is the reason you did not experience the behaviour that I reported. Cheers. Bryan

            Daniel Meyer added a comment -

            Maybe this can be fixed if the creation and caching of the script engine is done in the process application. Could solve CAM-3432 as well.

            Daniel Meyer added a comment - Maybe this can be fixed if the creation and caching of the script engine is done in the process application. Could solve CAM-3432 as well.

            Roman Smirnov added a comment - See fix for CAM-3432 : https://github.com/camunda/camunda-bpm-platform/commit/1f950d4036556d8c9790787a9cd71c7721e614f1 and the Testcase: https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/scriptengine/GroovyPaClassImportTest.java

            Roman Smirnov added a comment - See https://github.com/camunda/camunda-docs-manual/commit/f5c5f97a7c4a0370377723715451e1ad206496fe

              thorben.lindhauer Thorben Lindhauer
              bryan_evans@otpp.com Bryan Evans
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: