VMware Aria Automation Blog

from Stefan Schnell

Set JavaScript Access to Java Classes


To find a way to detect the used Java version I would like to use the following script:
var javaVersion = java.lang.System.getProperty("java.version");
System.log(javaVersion);
However, the use of Java classes, other than java.util.*, is limited, they must be explicitly enabled. You can find a description how to set JavaScript access to Java classes here. I try that exactly as described (but with release 8.9) and it does not work. vmware aria automation orchestrator set system properties
Different file names were tried, e.g. java_shutter_file or rhinofile. Furthermore different notations of the paths were tried out, like vco/usr/lib/vco/app-server/conf/rhinofile, /vco/usr/lib/vco/app-server/conf/rhinofile, data/vco/usr/lib/vco/app-server/conf/rhinofile, /data/vco/usr/lib/vco/app-server/conf/rhinofile etc. This was all tested with version 8.5.1 and 8.9.0. vmware aria automation orchestrator failed action
This is exactly the same error message as in a simulation where the ClassShutter is set on the same way.

context.setClassShutter(new ClassShutter() {
  public boolean visibleToScripts(String className) {
    if (
      className.startsWith("java.util")
    ) {
      return true;
    } else {
      return false;
    }
  }
});

console window
It looks like accessing classes, outside of java.util.*, does not work.

So, to get the Java version I tried another way. I set the system property com.vmware.js.allow-local-process to true.

console window
To get the Java version I used the following command sequence:
var com = new Command("jdk/bin/java --version");
com.execute(true);
System.log(com.output);
And this delivers these result:

console window
Now we see with Orchestrator 8.5.1 that Java version 11.0.12 is used and that it is an Zulu Azul distribution.

console window

The Orchestrator 8.10.2 and 8.12.0 uses the Java version 11.0.16.1. The Orchestrator 8.14.0 uses the Java version 17.0.8.1, the Orchestrator 8.16.2 uses Java version 17.0.10 and both are BellSoft distributions.
The vendor information is available in the java.vendor system property.

var javaVersion = java.lang.System.getProperty("java.version");
System.log(javaVersion);

var javaVendor = java.lang.System.getProperty("java.vendor");
System.log(javaVendor);

Good, but that does not help us one bit further with the problem with the shutter file. So I analyzed this problem again and found that the path of the class pattern shutter list, which is stored in the system property com.vmware.scripting.rhino-class-shutter-file, must be specified relative to the running container. The path described in the documentation is incorrect and your_configuration_file_subdirectory is already a bit misleading.

console window
The correct path is /usr/lib/vco/yourFileName.
In my example I use the file name PatternClassShutter.list. The location and the content is as described above.

console window
Great that Java can be used seamlessly on this way.

Addendum: The error in the documentation was corrected with release 8.11 on the 01.11.2023.