Code Macro Requirements

I failed to make it work with tomcat8 installation but tomcat7 worked fine. Also something was wrong with my Java installation which I used for other purposes so I installed java along the xwiki Ubuntu package:

deb stable/
package: “xwiki-tomcat7-mysql”

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 to false. I added the following line to the tomcat8 file:


After the fix I was able to execute successfully

    print "python"

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.

This is very weird since you definitely don’t need anything in the system side to use Jython in XWiki. As for the site module it’s part of jython-standalone JAR file in any cases.
Looks more like a classloader issue which makes Jython unable to find resources located in his JAR in Lib/ folder. Are you able to import other standard modules like math ?

Maybe you could try with Tomcat 7.

It happens when loading org.python.core. In org.python.core.imp.import_module_level() the first package part (= org) is tried to be loaded. A bit weird, but usually no problem. It fails only because of the Tomcat8 bug.

i have exactly the same problem as bjoerne. I am also stuck now with the code macro with the “String index out of range: 3” error message after adding the line in tomcat8 file as suggested by bjoerne.

See for Ubuntu side bug. has been create to follow progress on this issue.

The following ppa is supposed to contain a fixed version of Tomcat 8: Would be great if someone could test it.

I’ve got the same situation on the ubuntu.

But I found a simple solution but a little dirty. I manually upgraded tomcat to version 8.0.38 (by downloading debs for debian from internet) and downgraded jython to version 2.7.0. Now everything is ok, macros are fully functional.

So nobody wants to try ? I’m sure they would be happy on to have to validation if it’s working well so that they can apply it :slight_smile:

Hi. My Solution (Ubuntu LTS 16.04 with xwiki on TomCat 8 MySQL DB via DEB) was to download latest Tomcat 8 Release (tar.gz) and overwrite existing TomCat installation (i know its dirty :wink: )

service tomcat8 stop 
tar xvfz apache-tomcat-8.0.48.tar.gz
cd apache-tomcat-8.0.48
cp * /var/lib/tomcat8/ -Rv
service tomcat8 start

you should do a snapshot or a copy of the tomcat8 directory

It works!!!

sudo add-apt-repository ppa:nacc/tomcat8v2
sudo apt-get update
sudo apt-get install tomcat8=8.0.32-1ubuntu1.3~ppa2
sudo apt-get install tomcat8-common=8.0.32-1ubuntu1.3~ppa2
sudo apt-get install libtomcat8-java=8.0.32-1ubuntu1.3~ppa2
sudo service tomcat8 restart

Thank a lot for your help, @tmortagne !

1 Like

Thanks for the testing @bjoerne :slight_smile:

I added a note in

Works only for code macro but python macro doesn’t

That’s weird since the code macro essentially do the same than the python macro (it’s executing a python script using the exact same code that the python macro to use Pygments behind the scene).

There is a bug in jython 2.7.1
Downgrading to 2.7.0 solves the problem. I’d like to try 2.7.2a1 but cannot find a standalone version.

@silver-alx any details related to the bug you are referring to ? I did not noticed much issue in the context of XWiki (but I’m not doing much python).

This one -

Discussion with some details -

This looks very specific to CSV tool and the issue does not indicate it’s a regression only present in 2.7.1.

Anyway i’ve got this error and resolved it by downgrading ))

With XWiki 10.1 Tomcat 7 doesn’t seem to be an option any more. I used the instructions on DigitalOcean to install Tomcat 8.5.28 bypassing the Advanced Packaging Tool. Works fine for me.

Hmm indeed there seems to be an issue on Tomcat 7 because of el-api. We need to look at it since it’s not really expected…

Will release a 10.1.1 shortly with a fix.