The error was caused when jython tried to load the site python module which is not available in my installation.
The solution was to set the Java property python.import.site to false. I added the following line to the tomcat8 file:
After the fix I was able to execute successfully
But the Code Macro still doesn’t work. It causes a
java.lang.StringIndexOutOfBoundsException: String index out of range: 3
This is thrown when Tomcat tries to load a class org. This issue is mentioned in several tickets:
It should be fixed in Tomcat 8.0.33, but my Tomcat version on Ubuntu 16.04.3 is still 8.0.32-1ubuntu1.4. I guess I have to wait until there is an update available.