I’m using ubuntu 22.04 on AWS and set up openjdk 8, mysql 8, tomcat 9, openmrs platform 2.4.5 I can successfully see the tomcat response for localhost:8080 but I keep receiving the 404 response when I attempt localhost:8080/openmrs. The dump of the recent catalina.out is found here: sudo tail -n 200 /var/log/tomcat9/catalina.out[2025-11-03 18:31:24] [info] Sta - Pastebin.com
The catalina.out file isn’t very helpful; it just says this:
[2025-11-04 16:26:37] [crit] One or more listeners failed to start. Full details will be found in the appropriate container log file
[2025-11-04 16:26:37] [crit] Context [/openmrs] startup failed due to previous errors
If you can upload the appropriate log file, it may be possible to give you better direction.
Does this help at all?
It looks like OpenMRS hasn’t started any initialization since the openmrs property files, etc., were not created. Note, the .OpenMRS folder does not get any files
There should be a file called something like localhost.<date>.log I think that has the relevant parts in it. The bit about the “one or more listeners failed to start” is concerning because there’s a listener that’s basically the “entry point” for the application, so if that’s failing, I wouldn’t expect anything downstream of that (like the application directory) to show up.
Thanks much…..here’s the dump of that file. cat localhost.2025-11-04.log 04-Nov-2025 16:26:36.763 INFO [main] org.apache.c - Pastebin.com
Well, that’s a new one!
So this is actually an error being thrown while trying to initialize the logging system. More specifically, it’s trying create a directory like .OpenMRS/configuration. It appears that the attempt to create the directory fails and so it throws an exception. The exception itself would be easy to code around, but not so much the failure to be able to write to a directory.
Normally, openmrs tries to create the application directory in ~/.OpenMRS, where ~ is the home directory of whatever user OpenMRS is running as, so whatever user Tomcat is started as. Most likely, the failure to create a directory is down to a couple of possibilities:
- The user does not have a configured home directory. You might be able to get the tomcat user’s home directory (if you don’t know it and presuming you have a user named
tomcatwith something likegetent passwd | grep tomcat | cut -d: -f6 - The user does have a home directory configured, but cannot actually write to it. This is often the case with Linux daemon accounts that are just meant to run services. In that case, OpenMRS will not be able to create a directory where it expects and you will have to use one of the methods described here to set the OpenMRS application directory to somewhere else.
2 is way more likely than 1 and of the three options in the page I linked, it’s usually better to change the CATALINA_OPTS since that’s the least invasive.
So something like:
mkdir -p /var/lib/openmrs # substitute whatever path suits your purpose
chown tomcat:tomcat /var/lib/openmrs # subsitute with the user name of the user Tomcat runs as
I’m not exactly sure about Tomcat 9, but in previous versions of Tomcat, there’s a script called setenv.sh that’s meant for this kind of thing. You’d just add a line to it like this:
CATALINA_OPTS="$CATALINA_OPTS -DOPENMRS_APPLICATION_DATA_DIRECTORY=/var/lib/openmrs"
With that setup, all your files will be in /var/lib/openmrs (which is actually where they’re supposed to be when the home directory isn’t writable).
I created the setenv.sh file as you mentioned and restarted. Still the files that should be in openmrs are not there. I put the setenv.sh file in /usr/share/tomcat9/bin
Is that in the same directory as catalina.sh? Also, is there any output to the localhost.04-Nov-2025.log file? I easily could’ve misdiagnosed things…
setenv.sh is in the same directory as catalina.sh (/usr/share/tomcat9/bin). Here’s the latest tail for localhost.2025-11-05.log: pastebin
Looks like the same issue. Quick q: you said you “created” the setenv.sh file as in it wasn’t there? Do you know that the $CATALINA_BASE environment variable is set to?
If not, and assuming Tomcat is a standard systemd unit service, it’s probably in the output of cat $(systemctl show -P FragmentPath tomcat.service).
The file needs to be at $CATALINA_BASE/setenv.sh to be picked up.
Tomcat indicated CATALINA_BASE: /var/lib/tomcat9…I noted the other tomcat .sh files are at /usr/share/tomcat9/bin so I placed setenv.sh there, as well. I copied setenv to the folder /var/lib/tomcat9 and still get the same issue mentioned in the localhost log file. My only constraint is to use refapp 2.x Would you have a tech stack you use that might easily work on aws?
Many thanks for your assistance!