Permanent directory is ignored and data is in Tomcat work directory

I found the solution to this issue. In my case, it turns out that Debian packages Tomcat configured to be sandboxed, with write access only to certain directories, /var/lib/xwiki/data not being one of them. To solve, I had to create a systemd service override file to allow Tomcat to have write access to /var/lib/xwiki/data.

mkdir /etc/systemd/system/tomcat9.service.d/
echo -e "[Service]\nReadWritePaths=/var/lib/xwiki/data" > /etc/systemd/system/tomcat9.service.d/override.conf
systemctl daemon-reload
systemctl restart tomcat9.service

If you were already using XWiki and installed extensions and added attachments, you will need to move the data from the fallback directory to /var/lib/xwiki/data.

systemctl stop tomcat9.service
mv /var/cache/tomcat9/Catalina/localhost/xwiki/* /var/lib/xwiki/data/
systemctl start tomcat9.service
3 Likes