To find a way to detect the used Java version I would like to use the following script:
// Begin---------------------------------------------------------------- var javaVersion = java.lang.System.getProperty("java.version"); System.log(javaVersion); // End------------------------------------------------------------------
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 it does not work.
1. Create file with name rhino-class-shutter-file in the directory /data/vco/usr/lib/vco.
2. Set system property com.vmware.scripting.rhino-class-shutter-file to vco/usr/lib/vco/rhino-class-shutter-file. 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 tested with version 8.5.1 and 8.9.0.
3. After the restart of the Orchestration service and an new login into the vRA the error message 'TypeError: Cannot call property getProperty in object [JavaPackage java.lang.System], it is not a function, it is "object"' occures.
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, despite the configuration.
As far as I can see uses the Orchestrator 8.5.1 the Azul JDK Zulu 11.0.12.
What is my mistake? What else do I need to do to access Java classes via JavaScript?
Thanks for hints and tips.
This morning 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 today the file name PatternClassShutter.list. The location and the content is as described above.
Now all works as expected.
Great that Java can be used seamlessly on this way.
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:
Now we definitely 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 uses the Java version 11.0.16.1 and that is an BellSoft distribution. This information is available in the java.vendor system property.
var javaVendor = java.lang.System.getProperty("java.vendor");
System.log(javaVendor);
This morning 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 today the file name PatternClassShutter.list. The location and the content is as described above.
Now all works as expected.
Great that Java can be used seamlessly on this way.