Announcement

Collapse
No announcement yet.

Run Javascript in Channel Context Outside of Mirth

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Run Javascript in Channel Context Outside of Mirth

    Hi all; short time Mirther, first time poster, LONG time healthcare integration nerd going back to the STC Datagate days. Happy to be here

    I've searched this forum and scoured the web with no success ...

    Is there any way to execute JavaScript outside of running it in a channel? I've been trying to figure out a Rhino configuration that "sees" the packages Mirth includes so I can write utility functions in an external editor and speed up the code/test process a bit. Being able to do it in Eclipse or even Notepad++ (via NPPExec) would be fantastic. Not that I don't love the syntax highlighting and code completion in the Mirth editor, but the code/save/deploy/submit message/view log(s) process is a bit more ... fiddly than I'd prefer.

    I'm not looking to have a real-time debugger active (at least yet), but if that was an option with Eclipse I sure wouldn't kick it out of bed

    I've tried setting the classpath various ways and invoking Rhino from the server-lib directory with different combinations of command line options, but it keeps choking on attempts to load the mirth-supplied Java classes with the infamous "uncaught JavaScript runtime exception: TypeError: Cannot call property <method> in object [JavaPackage <package>]. It is not a function, it is "object".

    Everything I've read points to this being an issue with Rhino either unable to find the jar file(s) or that I'm running it under the wrong version of Java ... but:

    Code:
    C:\>java -version
    java version "1.8.0_211"
    Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)


    Thanks in advance for any help you can provide!
    Attached Files
    Last edited by Jeff Drumm; 06-19-2019, 09:36 AM. Reason: Change to a more accurate title

  • #2
    So ... I'm not sure whether I need to apologize to the moderators or not, but I'm going to do so proactively since I've been bugging them about the fact that this post hadn't appeared in the forum after I posted it. I'm now wondering whether it DID appear and I just missed it ...


    Anyway, I've figured out a partial solution to my original request using Notepad++, NPPExec and the Rhino interpreter and debugger included with Mirth Connect. This is handy for "quick 'n dirty" testing of code you intend to include in a transformer script or use as a function in a code template. There are probably ways to make it more useful than it is currently, too ...
    • Install the NppExec plugin
    • Enable the Console using Plugins | NppExec | Show Console
    • Select Plugins | NppExec | Execute
    • Enter the following in the Command(s) window:

    Code:
    ENV_SET CLASSPATH=.\*;.\commons\*;.\database\*;.\donkey\*;.\javax\*;.\jersey\*;.\jms\*;.\swagger\*
    set rhinover=200
    CD C:\Program Files\Mirth Connect\server-lib
    NPP_SAVE
    java org.mozilla.javascript.tools.shell.Main -version $(rhinover)  "$(FULL_CURRENT_PATH)"
    • Click Save and enter a command name (I used "Run Javascript")
    • In the line that begins with the word "java" {the last line), change the word "shell" to "debugger"
    • Click Save and enter a command name (I used "Debug Javascript")

    Save your file and choose Run Javascript to execute and view the output/errors in the console window. Alternately you can select Debug Javascript and it will launch the Rhino GUI debugger. You'll have to exit the debugger if you want to launch it again after re-saving your file. Alternately you can go to the File menu in the debugger and reload it.

    I haven't tried any message parsing/manipulation with E4X yet, so I don't know that this will be usable for that. At least I can test general string/date/number manipulation and invoke Java methods available via the Packages interface (such as the org.apache.commons.ssl.OpenSSL.encrypt/decrypt methods) without the save/deploy/trigger channel/view logs cycle from within Mirth.

    If this is stupid or otherwise useless, let me know. I can take it
    Last edited by Jeff Drumm; 06-18-2019, 07:18 PM.

    Comment


    • #3
      Great first post! I use the interactive rhino shell all the time. Neat what you did to integrate it with Notepad++. e4x most definitely works.

      Your class paths hit a good deal of what you might need. What are you missing is all of the plugins in the extensions directory (rather than server-lib.) This includes all of the data types (and their related serializers.)

      Comment


      • #4
        Originally posted by agermano View Post
        Great first post! I use the interactive rhino shell all the time. Neat what you did to integrate it with Notepad++. e4x most definitely works.

        Your class paths hit a good deal of what you might need. What are you missing is all of the plugins in the extensions directory (rather than server-lib.) This includes all of the data types (and their related serializers.)

        Thanks! I'll update the initial post as I get the CLASSPATH requirements figured out.


        EDIT: Yikes! There's a LOT of stuff in the extensions directory. I'm no Java expert, but I understand that it doesn't recurse directories in the CLASSPATH so I'd need one that contains all of them (or perhaps multiple NPPExec scripts each containing a classpath with a subset of them, depending on what sort of script you want to execute/debug).


        I've made other changes to the NPPExec configuration that provide a cleaner output (background and text colors, filters) and I'll include those as well. Stay tuned ...
        Last edited by Jeff Drumm; 06-18-2019, 06:53 PM. Reason: Required a Yikes!

        Comment


        • #5
          Also, the SerializerFactory from the User API doesn't work outside of mirth because it checks with the controllers to see which data types are currently registered.

          You can still build them yourself, though.

          Code:
          var deserializationProperties = new com.mirth.connect.plugins.datatypes.hl7v2.HL7v2DeserializationProperties();
          var serializationProperties = new com.mirth.connect.plugins.datatypes.hl7v2.HL7v2SerializationProperties();
          var serializerProperties = new com.mirth.connect.model.datatype.SerializerProperties(serializationProperties,deserializationProperties,null);
          var ser = new com.mirth.connect.plugins.datatypes.hl7v2.ER7Serializer(serializerProperties);
          var msg = new XML(ser.toXML('DG1|1||250.00^^I9'));
          msg.DG1['DG1.1']['DG1.1.1'] = 2;
          var encoded = ser.fromXML(msg.toXMLString());
          // DG1|2||250.00^^I9

          Comment


          • #6
            Originally posted by agermano View Post
            Also, the SerializerFactory from the User API doesn't work outside of mirth because it checks with the controllers to see which data types are currently registered.

            You can still build them yourself, though.

            Code:
            var deserializationProperties = new com.mirth.connect.plugins.datatypes.hl7v2.HL7v2DeserializationProperties();
            var serializationProperties = new com.mirth.connect.plugins.datatypes.hl7v2.HL7v2SerializationProperties();
            var serializerProperties = new com.mirth.connect.model.datatype.SerializerProperties(serializationProperties,deserializationProperties,null);
            var ser = new com.mirth.connect.plugins.datatypes.hl7v2.ER7Serializer(serializerProperties);
            var msg = new XML(ser.toXML('DG1|1||250.00^^I9'));
            msg.DG1['DG1.1']['DG1.1.1'] = 2;
            var encoded = ser.fromXML(msg.toXMLString());
            // DG1|2||250.00^^I9

            Ahh, good stuff. We need a "like" button

            Comment


            • #7
              Another thing you'll want to do is set the appropriate Rhino language version when you launch the shell. I'm assuming you found this already https://developer.mozilla.org/en-US/...ts/Rhino/Shell

              For all mirth versions prior to 3.7 mirth runs with version 0 (I realize they don't list it as a valid option on that page, but it is.) They call this the "default" version. It's roughly equivalent to 160.

              In 3.7 they let you specify the rhino version in the mirth.properties file. If you upgrade to 3.7 from a prior version it will keep the version of default. In a fresh install it will be set to ES6, which is actually Rhino version 200. The rhino that ships with 3.7 will launch the shell in version 180 if you don't specify.
              Last edited by agermano; 06-18-2019, 07:08 PM.

              Comment


              • #8
                Originally posted by agermano View Post
                Another thing you'll want to do is set the appropriate Rhino language version when you launch the shell. I'm assuming you found this already https://developer.mozilla.org/en-US/...ts/Rhino/Shell

                For all mirth versions prior to 3.7 mirth runs with version 0 (I realize they don't list it as a valid option on that page, but it is.) They call this the "default" version. It's roughly equivalent to 160.

                In 3.7 they let you specify the rhino version in the mirth.properties file. If you upgrade to 3.7 from a prior version it will keep the version of default. In a fresh install it will be set to ES6, which is actually Rhino version 200. The rhino that ships with 3.7 will launch the shell in version 180 if you don't specify.

                Didn't catch that, thanks. I've updated the sample script in the second post to set it to 200 (I'm at MC 3.7.1). Y'all are welcome to set it to whatever version suits you

                Comment


                • #9
                  Ok, change in plans.

                  I couldn't get NPPExec to set the full CLASSPATH; I think there's a string length limitation of 1,024 bytes for the variable's value in its ENV_SET function. So here's what I've done ...

                  I created a Windows .CMD file called runRhino.cmd in a directory I use for utility scripts so that they don't get clobbered by software reinstallations or cleanups (C:\bin\ ):
                  Code:
                  @ECHO OFF
                  SET MIRTHDIR=C:\Program Files\Mirth Connect\
                  SET CLASS=%1
                  SET VER=%2
                  SET FILE=%3
                  CD %MIRTHDIR%
                  SET CLASSPATH=.\server-lib\*;.\server-lib\commons\*;.\server-lib\database\*;.\server-lib\donkey\*;.\server-lib\javax\*;.\server-lib\jersey\*;.\server-lib\jetty\*;.\server-lib\jms\*;.\server-lib\swagger\*;.\server-lib\javax\jaxb\*;.\server-lib\javax\jaxws\*;.\server-lib\javax\jaxb\ext\*;.\server-lib\javax\jaxws\ext\*;.\server-lib\jersey\ext\*;.\server-lib\jetty\jsp\*;.\server-lib\swagger\ext\*;.\custom-lib\*;.\extensions\*;.\extensions\dashboardstatus\*;.\extensions\datapruner\*;.\extensions\datatype-delimited\*;.\extensions\datatype-dicom\*;.\extensions\datatype-edi\*;.\extensions\datatype-hl7v2\*;.\extensions\datatype-hl7v3\*;.\extensions\datatype-json\*;.\extensions\datatype-ncpdp\*;.\extensions\datatype-raw\*;.\extensions\datatype-xml\*;.\extensions\destinationsetfilter\*;.\extensions\dicom\*;.\extensions\dicomviewer\*;.\extensions\directoryresource\*;.\extensions\doc\*;.\extensions\extensionmanager\*;.\extensions\file\*;.\extensions\globalmapviewer\*;.\extensions\http\*;.\extensions\httpauth\*;.\extensions\imageviewer\*;.\extensions\javascriptrule\*;.\extensions\javascriptstep\*;.\extensions\jdbc\*;.\extensions\jms\*;.\extensions\js\*;.\extensions\mapper\*;.\extensions\messagebuilder\*;.\extensions\mllpmode\*;.\extensions\pdfviewer\*;.\extensions\rulebuilder\*;.\extensions\scriptfilerule\*;.\extensions\scriptfilestep\*;.\extensions\serverlog\*;.\extensions\smtp\*;.\extensions\tcp\*;.\extensions\textviewer\*;.\extensions\vm\*;.\extensions\ws\*;.\extensions\xsltstep\*;.\extensions\dicom\lib\*;.\extensions\dicomviewer\lib\*;.\extensions\doc\lib\*;.\extensions\file\lib\*;.\extensions\httpauth\src\*;.\extensions\pdfviewer\lib\*
                  java org.mozilla.javascript.tools.%CLASS%.Main -version %VER% %FILE%
                  I then replaced the Run Javascript command with:
                  Code:
                  set rhinover=200
                  NPP_SAVE
                  C:\bin\runRhino.cmd shell $(rhinover) "$(FULL_CURRENT_PATH)"
                  And the Debug Javascript command with:
                  Code:
                  set rhinover=200
                  NPP_SAVE
                  C:\bin\runRhino.cmd debugger $(rhinover)  "$(FULL_CURRENT_PATH)"
                  Seems to work, so far. Fingers crossed!
                  Last edited by Jeff Drumm; 06-20-2019, 06:04 PM. Reason: CLASSPATH incorrrect

                  Comment


                  • #10
                    Question for the mods: The thread title doesn't really describe how this all ended up. Would it be possible to change it to something like "Testing Mirth/Rhino JavaScript in NotePad++?"

                    Comment


                    • #11
                      I took inspiration from your Notepad++ solution and set up something similar in vscode. I haven't actually tested this on Windows, but it works on linux.

                      A note for your config, all of your .\extensions\* entries in the classpath need to be moved up to the parent folder (..\extensions\*)

                      Also, that debugger is pretty slick. Prior to getting this set up, I had only ever run the shell in interactive mode in a headless environment, so I never tried it to see how it worked.

                      These are set up as build tasks. Whichever one you configure as the default will run when you press Shift+Ctrl+B.

                      https://code.visualstudio.com/docs/e...#_custom-tasks

                      Code:
                      {
                          // See https://go.microsoft.com/fwlink/?LinkId=733558
                          // for the documentation about the tasks.json format
                          "version": "2.0.0",
                          "tasks": [
                              {
                                  "label": "Run in Rhino shell",
                                  "type": "process",
                                  "command": "java",
                                  "args": [
                                      "org.mozilla.javascript.tools.shell.Main",
                                      "-version",
                                      "200",
                                      "${file}"
                                  ],
                                  "options": {
                                      "env": {
                                          "CLASSPATH": "./*:./commons/*:./database/*:./donkey/*:./javax/*:./jersey/*:./jetty/*:./jms/*:./swagger/*:./javax/jaxb/*:./javax/jaxws/*:./javax/jaxb/ext/*:./javax/jaxws/ext/*:./jersey/ext/*:./jetty/jsp/*:./swagger/ext/*:./custom-lib/*:../extensions/dashboardstatus/*:../extensions/datapruner/*:../extensions/datatype-delimited/*:../extensions/datatype-dicom/*:../extensions/datatype-edi/*:../extensions/datatype-hl7v2/*:../extensions/datatype-hl7v3/*:../extensions/datatype-json/*:../extensions/datatype-ncpdp/*:../extensions/datatype-raw/*:../extensions/datatype-xml/*:../extensions/destinationsetfilter/*:../extensions/dicom/*:../extensions/dicomviewer/*:../extensions/directoryresource/*:../extensions/doc/*:../extensions/extensionmanager/*:../extensions/file/*:../extensions/globalmapviewer/*:../extensions/http/*:../extensions/httpauth/*:../extensions/imageviewer/*:../extensions/javascriptrule/*:../extensions/javascriptstep/*:../extensions/jdbc/*:../extensions/jms/*:../extensions/js/*:../extensions/mapper/*:../extensions/messagebuilder/*:../extensions/mllpmode/*:../extensions/pdfviewer/*:../extensions/rulebuilder/*:../extensions/scriptfilerule/*:../extensions/scriptfilestep/*:../extensions/serverlog/*:../extensions/smtp/*:../extensions/tcp/*:../extensions/textviewer/*:../extensions/vm/*:../extensions/ws/*:../extensions/xsltstep/*:../extensions/dicom/lib/*:../extensions/dicomviewer/lib/*:../extensions/doc/lib/*:../extensions/file/lib/*:../extensions/httpauth/src/*:../extensions/pdfviewer/lib/*:../extensions/ws/lib/*"
                                      },
                                      "cwd": "/home/tony/mirth/release/3.7.1/server-lib"
                                  },
                                  "windows": {
                                      "options": {
                                          "env": {
                                              "CLASSPATH": ".\\*;.\\commons\\*;.\\database\\*;.\\donkey\\*;.\\javax\\*;.\\jersey\\*;.\\jetty\\*;.\\jms\\*;.\\swagger\\*;.\\javax\\jaxb\\*;.\\javax\\jaxws\\*;.\\javax\\jaxb\\ext\\*;.\\javax\\jaxws\\ext\\*;.\\jersey\\ext\\*;.\\jetty\\jsp\\*;.\\swagger\\ext\\*;.\\custom-lib\\*;..\\extensions\\dashboardstatus\\*;..\\extensions\\datapruner\\*;..\\extensions\\datatype-delimited\\*;..\\extensions\\datatype-dicom\\*;..\\extensions\\datatype-edi\\*;..\\extensions\\datatype-hl7v2\\*;..\\extensions\\datatype-hl7v3\\*;..\\extensions\\datatype-json\\*;..\\extensions\\datatype-ncpdp\\*;..\\extensions\\datatype-raw\\*;..\\extensions\\datatype-xml\\*;..\\extensions\\destinationsetfilter\\*;..\\extensions\\dicom\\*;..\\extensions\\dicomviewer\\*;..\\extensions\\directoryresource\\*;..\\extensions\\doc\\*;..\\extensions\\extensionmanager\\*;..\\extensions\\file\\*;..\\extensions\\globalmapviewer\\*;..\\extensions\\http\\*;..\\extensions\\httpauth\\*;..\\extensions\\imageviewer\\*;..\\extensions\\javascriptrule\\*;..\\extensions\\javascriptstep\\*;..\\extensions\\jdbc\\*;..\\extensions\\jms\\*;..\\extensions\\js\\*;..\\extensions\\mapper\\*;..\\extensions\\messagebuilder\\*;..\\extensions\\mllpmode\\*;..\\extensions\\pdfviewer\\*;..\\extensions\\rulebuilder\\*;..\\extensions\\scriptfilerule\\*;..\\extensions\\scriptfilestep\\*;..\\extensions\\serverlog\\*;..\\extensions\\smtp\\*;..\\extensions\\tcp\\*;..\\extensions\\textviewer\\*;..\\extensions\\vm\\*;..\\extensions\\ws\\*;..\\extensions\\xsltstep\\*;..\\extensions\\dicom\\lib\\*;..\\extensions\\dicomviewer\\lib\\*;..\\extensions\\doc\\lib\\*;..\\extensions\\file\\lib\\*;..\\extensions\\httpauth\\src\\*;..\\extensions\\pdfviewer\\lib\\*;..\\extensions\\ws\\lib\\*"
                                          },
                                          "cwd": "C:\\Program Files\\Mirth Connect\\server-lib"
                                      }
                                  },
                                  "group": {
                                      "kind": "build",
                                      "isDefault": true
                                  }
                              },
                              {
                                  "label": "Debug in Rhino",
                                  "type": "process",
                                  "command": "java",
                                  "args": [
                                      "org.mozilla.javascript.tools.debugger.Main",
                                      "-version",
                                      "200",
                                      "${file}"
                                  ],
                                  "options": {
                                      "env": {
                                          "CLASSPATH": "./*:./commons/*:./database/*:./donkey/*:./javax/*:./jersey/*:./jetty/*:./jms/*:./swagger/*:./javax/jaxb/*:./javax/jaxws/*:./javax/jaxb/ext/*:./javax/jaxws/ext/*:./jersey/ext/*:./jetty/jsp/*:./swagger/ext/*:./custom-lib/*:../extensions/dashboardstatus/*:../extensions/datapruner/*:../extensions/datatype-delimited/*:../extensions/datatype-dicom/*:../extensions/datatype-edi/*:../extensions/datatype-hl7v2/*:../extensions/datatype-hl7v3/*:../extensions/datatype-json/*:../extensions/datatype-ncpdp/*:../extensions/datatype-raw/*:../extensions/datatype-xml/*:../extensions/destinationsetfilter/*:../extensions/dicom/*:../extensions/dicomviewer/*:../extensions/directoryresource/*:../extensions/doc/*:../extensions/extensionmanager/*:../extensions/file/*:../extensions/globalmapviewer/*:../extensions/http/*:../extensions/httpauth/*:../extensions/imageviewer/*:../extensions/javascriptrule/*:../extensions/javascriptstep/*:../extensions/jdbc/*:../extensions/jms/*:../extensions/js/*:../extensions/mapper/*:../extensions/messagebuilder/*:../extensions/mllpmode/*:../extensions/pdfviewer/*:../extensions/rulebuilder/*:../extensions/scriptfilerule/*:../extensions/scriptfilestep/*:../extensions/serverlog/*:../extensions/smtp/*:../extensions/tcp/*:../extensions/textviewer/*:../extensions/vm/*:../extensions/ws/*:../extensions/xsltstep/*:../extensions/dicom/lib/*:../extensions/dicomviewer/lib/*:../extensions/doc/lib/*:../extensions/file/lib/*:../extensions/httpauth/src/*:../extensions/pdfviewer/lib/*:../extensions/ws/lib/*"
                                      },
                                      "cwd": "/home/tony/mirth/release/3.7.1/server-lib"
                                  },
                                  "windows": {
                                      "options": {
                                          "env": {
                                              "CLASSPATH": ".\\*;.\\commons\\*;.\\database\\*;.\\donkey\\*;.\\javax\\*;.\\jersey\\*;.\\jetty\\*;.\\jms\\*;.\\swagger\\*;.\\javax\\jaxb\\*;.\\javax\\jaxws\\*;.\\javax\\jaxb\\ext\\*;.\\javax\\jaxws\\ext\\*;.\\jersey\\ext\\*;.\\jetty\\jsp\\*;.\\swagger\\ext\\*;.\\custom-lib\\*;..\\extensions\\dashboardstatus\\*;..\\extensions\\datapruner\\*;..\\extensions\\datatype-delimited\\*;..\\extensions\\datatype-dicom\\*;..\\extensions\\datatype-edi\\*;..\\extensions\\datatype-hl7v2\\*;..\\extensions\\datatype-hl7v3\\*;..\\extensions\\datatype-json\\*;..\\extensions\\datatype-ncpdp\\*;..\\extensions\\datatype-raw\\*;..\\extensions\\datatype-xml\\*;..\\extensions\\destinationsetfilter\\*;..\\extensions\\dicom\\*;..\\extensions\\dicomviewer\\*;..\\extensions\\directoryresource\\*;..\\extensions\\doc\\*;..\\extensions\\extensionmanager\\*;..\\extensions\\file\\*;..\\extensions\\globalmapviewer\\*;..\\extensions\\http\\*;..\\extensions\\httpauth\\*;..\\extensions\\imageviewer\\*;..\\extensions\\javascriptrule\\*;..\\extensions\\javascriptstep\\*;..\\extensions\\jdbc\\*;..\\extensions\\jms\\*;..\\extensions\\js\\*;..\\extensions\\mapper\\*;..\\extensions\\messagebuilder\\*;..\\extensions\\mllpmode\\*;..\\extensions\\pdfviewer\\*;..\\extensions\\rulebuilder\\*;..\\extensions\\scriptfilerule\\*;..\\extensions\\scriptfilestep\\*;..\\extensions\\serverlog\\*;..\\extensions\\smtp\\*;..\\extensions\\tcp\\*;..\\extensions\\textviewer\\*;..\\extensions\\vm\\*;..\\extensions\\ws\\*;..\\extensions\\xsltstep\\*;..\\extensions\\dicom\\lib\\*;..\\extensions\\dicomviewer\\lib\\*;..\\extensions\\doc\\lib\\*;..\\extensions\\file\\lib\\*;..\\extensions\\httpauth\\src\\*;..\\extensions\\pdfviewer\\lib\\*;..\\extensions\\ws\\lib\\*"
                                          },
                                          "cwd": "C:\\Program Files\\Mirth Connect\\server-lib"
                                      }
                                  },
                                  "group": "build"
                              }
                          ]
                      }

                      Comment


                      • #12
                        Thanks for the feedback. Actually, I discovered the classpath issue earlier today and updated the post this evening, but I must have done that some time after you grabbed it.


                        I don't understand why I can't run a script that creates a database connection object using DatabaseConnectionFactory.createDatabaseConnection (), though. I get the error "js: uncaught JavaScript runtime exception: ReferenceError: "DatabaseConnectionFactory" is not defined."


                        Any thoughts?


                        EDIT: Oh, and nice work on the VSCode config!
                        Last edited by Jeff Drumm; 06-20-2019, 07:32 PM.

                        Comment


                        • #13
                          Mirth does a lot of setup of the javascript context, adding references to things that won't be available in this environment, importing the User API classes, adding helper functions, etc...


                          If you add this to the top of your file, you'll get most of the User API.

                          Code:
                          importPackage(com.mirth.connect.server.userutil);
                          Otherwise, you can specify the full path to the class.

                          Code:
                          com.mirth.connect.server.userutil.DatabaseConnectionFactory.createDatabaseConnection()
                          Edit: A third option would be to create a reference to the Rhino JavaClass
                          Code:
                          const DatabaseConnectionFactory = com.mirth.connect.server.userutil.DatabaseConnectionFactory;
                          Last edited by agermano; 06-20-2019, 07:40 PM.

                          Comment


                          • #14
                            So, you can actually create your own initialization script. I created a new file.

                            init_rhino.js:
                            Code:
                            importPackage(com.mirth.connect.server.userutil);
                            Then you pass an extra parameter when you launch the shell
                            Code:
                            java org.mozilla.javascript.tools.shell.Main -version 200 -e "load('/home/tony/mirth/release/3.7.1/js-lib/init_rhino.js')" %FILE%
                            The shell executes what you pass in with -e before it starts executing your file.

                            It doesn't seem to work with the debugger, unfortunately, but you can add the load statement as the first line of your file in either case to setup your default environment instead of passing it as an argument.

                            Comment


                            • #15
                              Thanks again!

                              Now if only I can figure out why your suggestion for importPackage() isn't working

                              Closer, though ... I'm getting the error:
                              Code:
                              js: Java class "com.mirth.connect.server.userutil.DatabaseConnectionFactory" has no public instance field or method named "createDatabaseConnection".
                              now. Seems as though it's finding the class but not the methods ...


                              EDIT: I also tried specifying the full path to the class and creating a reference with const. Same result
                              Last edited by Jeff Drumm; 06-21-2019, 05:24 AM. Reason: other attempts

                              Comment

                              Working...
                              X