YT04‐Configure database environment variable in Tomcat - zhamri/CSC584-Enterprise_Programming GitHub Wiki
Install psql
sudo apt update
sudo apt install postgresql-client-common
Where is Tomcat located?
ps aux | grep tomcat
Tomcat paths
-Dcatalina.base=/var/lib/tomcat10
-Dcatalina.home=/usr/share/tomcat10
| Type | Path |
|---|---|
| CATALINA_BASE (runtime config) | /var/lib/tomcat10 |
| CATALINA_HOME (installation) | /usr/share/tomcat10 |
Open config file
vim /etc/default/tomcat10
Add your variables
If you use System.getProperty(...)
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -DAPP_DB_URL=jdbc:postgresql://aws-1-ap-southeast-1.pooler...
Choose
Transaction Poolerhost to ensure the server uses a reachable IPv4 endpoint. Otherwise, you will get "Network is unreachable"
Restart Tomcat
systemctl restart tomcat10
Check Tomcat status
systemctl status tomcat10