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.
- Create a file with name
rhino-class-shutter-file
in the directory /data/vco/usr/lib/vco
.
- Set system property
com.vmware.scripting.rhino-class-shutter-file
to vco/usr/lib/vco/rhino-class-shutter-file
.
Hint: This configuration is stored in the file vmo-managed.properties
in the location /data/vco/usr/lib/vco/app-server/conf
.
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.
- After the restart of the Orchestration service and an new login into Aria Automation the error message occurs:
TypeError: Cannot call property getProperty in object [JavaPackage java.lang.System], it is not a function, it is "object"
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;
}
}
});
|
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.
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:
Hint: The Command object is not available from Aria Automation release 8.17.0 until 8.18.0.
Now we see with Orchestrator 8.5.1 that Java version 11.0.12 is used and that it is an Zulu Azul distribution.
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, 8.16.2 uses Java 17.0.10, 8.18.0 uses Java 17.0.11 and all are
BellSoft distributions.
The vendor information is available in the
java.vendor
system property.
var javaVendor = java.lang.System.getProperty("java.vendor");
System.log(javaVendor);
var javaVersion = java.lang.System.getProperty("java.version");
System.log(javaVersion);
var javaVmVersion = java.lang.System.getProperty("java.vm.version");
System.log(javaVmVersion);
var osName = java.lang.System.getProperty("os.name");
System.log(osName);
var osVersion = java.lang.System.getProperty("os.version");
System.log(osVersion);
var osArchitecture = java.lang.System.getProperty("os.arch");
System.log(osArchitecture);
|
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.
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.
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.