Code Macro Requirements

#15

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 http://maven.xwiki.org stable/
package: “xwiki-tomcat7-mysql”

0 Likes

#16

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:

JAVA_OPTS="${JAVA_OPTS} -Dpython.import.site=false"

After the fix I was able to execute successfully

{{python}}
    print "python"
{{/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.

0 Likes

#17

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.

0 Likes

#18

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.

0 Likes

#19

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.

0 Likes

#20

See https://bugs.launchpad.net/ubuntu/+source/tomcat8/+bug/1644144 for Ubuntu side bug. https://jira.xwiki.org/browse/XWIKI-14924 has been create to follow progress on this issue.

The following ppa is supposed to contain a fixed version of Tomcat 8: https://launchpad.net/~nacc/+archive/ubuntu/tomcat8v2. Would be great if someone could test it.

0 Likes

#21

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.

0 Likes

#22

So nobody wants to try https://launchpad.net/~nacc/+archive/ubuntu/tomcat8v2 ? I’m sure they would be happy on https://bugs.launchpad.net/ubuntu/+source/tomcat8/+bug/1644144 to have to validation if it’s working well so that they can apply it :slight_smile:

0 Likes

#23

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

0 Likes

#24

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

#25

Thanks for the testing @bjoerne :slight_smile:

I added a note in http://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationViaAPT/#HTomcat.

0 Likes

#26

Works only for code macro but python macro doesn’t

0 Likes

#27

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).

0 Likes

#28

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.

0 Likes

#29

@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).

0 Likes

#30

This one - http://bugs.jython.org/issue2632

Discussion with some details - https://github.com/jythontools/jython/issues/90

0 Likes

#31

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

0 Likes

#32

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

0 Likes

#33

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.

0 Likes

#34

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.

0 Likes