Xwiki.properties environment.permanentDirectory change not working Ubuntu 20.04

Unable to successfully change xwiki.properties environment.permanentDirectory to store persistent data and in particular attachments on a larger partition.

I was able to similarly change the mariadb directory.

sudo service tomcat9 stop
sudo service mariadb stop

Edit configuration /etc/xwiki/xwiki.properties changing environment.permanentDirectory from /var/lib/xwiki/data to /disk2/xwiki/data

cd /var/lib/

Make a copy to bigger partition

sudo cp -pR xwiki /disk2
sudo systemctl start mariadb
sudo service tomcat9 start

sudo journalctl -u tomcat9 --since “17:03”


Aug 09 17:04:05 obl-xwiki.sri.utoronto.ca tomcat9[447278]: 2021-08-09 17:04:05,578 [main] ERROR o.x.e.i.ServletEnvironment - Configured permanent directory [/disk2/xwiki/data] is not writable.
Aug 09 17:04:05 obl-xwiki.sri.utoronto.ca tomcat9[447278]: 2021-08-09 17:04:05,579 [main] WARN o.x.e.i.ServletEnvironment - Falling back on [/var/cache/tomcat9/Catalina/localhost/xwiki] as the permanent directory.
Aug 09 17:04:05 obl-xwiki.sri.utoronto.ca tomcat9[447278]: 2021-08-09 17:04:05,580 [main] INFO o.x.e.i.ServletEnvironment - Using permanent directory [/var/cache/tomcat9/Catalina/localhost/xwiki]

Directory ownership looks ok compared to original
ls -ltdr /var/lib/xwiki/data /disk2/xwiki/data/
drwxr-xr-x 7 tomcat tomcat 4096 Aug 3 15:42 /var/lib/xwiki/data
drwxr-xr-x 7 tomcat tomcat 4096 Aug 3 15:42 /disk2/xwiki/data/

I even modified /etc/apparmor.d/tunables/alias as a last resort as I had to do for mysql to no effect

more /etc/apparmor.d/tunables/alias

alias /var/lib/mysql → /disk2/mysql,
/var/lib/xwiki/data → /disk2/xwiki/data,

System:

dpkg -l | egrep -i “(tomcat9|xwiki*common)”
ii libtomcat9-java 9.0.31-1ubuntu0.1 all Apache Tomcat 9 - Servlet and JSP engine – core libraries
ii tomcat9 9.0.31-1ubuntu0.1 all Apache Tomcat 9 - Servlet and JSP engine
ii tomcat9-common 9.0.31-1ubuntu0.1 all Apache Tomcat 9 - Servlet and JSP engine – common files
ii xwiki-tomcat9-common 13.6 all XWiki is a free wiki software platform written in Java with a design emphasis
ii xwiki-tomcat9-mariadb 13.6 all XWiki is a free wiki software platform written in Java with a design emphasis

This one is indeed not obvious: on recent Debian/Ubuntu versions, this is because of Tomcat 9 systemd setup, actually. You have to explicitly indicate to systemd all the folders Tomcat is allowed to access.

Take a look at /etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf.

Wow it would have taken me awhile, thank you. Did not think that systemd would be at play. The change you proposed fixed my access problem. SOLVED.

About to post another problem for you :slight_smile: Convenient that your authored the functionality.