Download a Template for Import Germplasm doesn't work in LInux Installation

Problem

Download a Template for Import Germplasm doesn't work in LInux Installation

Solution

I found out that in this particular server, when a user downloads a germplasm list template, BMS will try to write a temporary file in the "User Working Directory" -- in Java this is the {{System.getProperty("user.dir")}} property variable -- which resolves to the *Linux's root directory ("/")*. The *tomcat* user doesn't have a write permission to this directory that's why it's throwing a permission denied error.

We cannot add write permission to the root directory for security reason, so as a workaround, I the tomcat startup script ({{/etc/init.d/tomcat}}) needs to be edited to add a command that will change the working directory when Tomcat is started by the system ({{cd /home/tomcat}})


Example:
{code}
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.50

cd /home/tomcat

case $1 in
start)
/bin/su tomcat $CATALINA_HOME/bin/startup.sh
;;
stop)
/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh
;;
restart)
/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh
/bin/su tomcat $CATALINA_HOME/bin/startup.sh
;;
{code}

When {{cd /home/tomcat}} is executed before {{startup.sh}} is called, it will change the working directory to {{/home/tomcat}}. This directory has write permission for *tomcat* user. I already applied the fix in the server, so downloading of germplasm template file should now work.

Screenshot of the tomcat script in the server: