Getting the back-end to connect to a SQLite database

My apologies I’m still fairly new to Docker. Anyway, I started fresh.

On the openmrs-core project where my changes are, I ran:

docker compose build --build-arg MVN_ARGS='install -DskipTests'

This created the image openmrs/openmrs-core:dev which I then specified on a newly cloned openmrs-distro-platform project where I created a new file:

# docker-compose.sqlite.yml
version: "3.7"

services:
  api:
    # image: openmrs/openmrs-platform:${TAG:-nightly}
    image: openmrs/openmrs-core:${TAG:-dev} # image built with the changes I made
    build: .
    ports:
      - "8080:8080"
    environment:
      OMRS_MODULE_WEB_ADMIN: "true"
      OMRS_AUTO_UPDATE_DATABASE: "true"
      OMRS_CREATE_TABLES: "true"

      OMRS_DB_DRIVER_CLASS: ${OMRS_DB_DRIVER_CLASS:-org.sqlite.JDBC}
      OMRS_DB_URL: ${OMRS_DB_URL:-jdbc:sqlite:/openmrs/data/database.sqlite3}
      OMRS_HIBERNATE_DIALECT: ${OMRS_HIBERNATE_DIALECT:-org.sqlite.hibernate.dialect.SQLiteDialect}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/openmrs"]
      timeout: 5s
    volumes:
      - openmrs-data:/openmrs/data/
      - ${PWD}/sqlite/database.sqlite3:/openmrs/data/database.sqlite3

volumes:
  openmrs-data:

I then ran

docker compose -f docker-compose.sqlite.yml up -d

The openmrs-distro-platform-api-1 container seems to be running just fine. But when I used Postman to make an HTTP request to get the system information:

http://localhost:8080/openmrs/ws/rest/v1/systeminformation

I got this error on the container’s logs:

No mapping for GET /openmrs/ws/rest/v1/systeminformation

Any idea on where I went wrong?

Sorry if I came off a bit harsh there!

This is actually the kind of error I would’ve expected you to see. Most likely, there was some issue starting OpenMRS in this configuration, so the REST module never started correctly. Are you able to get the logs from the compose image? (docker compose logs api).

PS it might be best to try http://localhost:8080/openmrs/ws/rest/v1/session; this will likely give you the same result, but that endpoint shouldn’t require authentication.

No worries, it didn’t really come off that way - I was apologizing for asking some really basic Docker concepts.

I actually had a different idea of why I’m getting that error. I remember you mentioned before that the openmrs-core repo doesn’t have the REST module bundled with it. And with me replacing the image on the docker compose file from openmrs-platform:nightly to openmrs-core:dev, the REST module isn’t there. At least that’s my understanding. Anyway, here are the contents of the logs you asked for:

$ docker compose logs api
openmrs-distro-platform-api-1  | Initiating OpenMRS startup
openmrs-distro-platform-api-1  | Deleting modules, OWAs and configuration from OpenMRS
openmrs-distro-platform-api-1  | Loading distribution artifacts into OpenMRS
openmrs-distro-platform-api-1  | Writing out /openmrs/openmrs-server.properties
openmrs-distro-platform-api-1  | Clearing out Tomcat directories
openmrs-distro-platform-api-1  | Loading WAR into appropriate location
openmrs-distro-platform-api-1  | Writing out /usr/local/tomcat/bin/setenv.sh file
openmrs-distro-platform-api-1  | Starting up OpenMRS...
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.580 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/8.5.83
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.582 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Oct 3 2022 21:11:09 UTC
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.582 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.83.0
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            5.15.49-linuxkit
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-1.8.0-amazon-corretto/jre
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_362-b08
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Amazon.com Inc.
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.583 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=UTF-8
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.security.egd=file:/dev/./urandom
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headless=true
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headlesslib=true
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.584 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.585 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.586 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:NewSize=128m
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.586 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -DOPENMRS_INSTALLATION_SCRIPT=/openmrs/openmrs-server.properties
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.587 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -DOPENMRS_APPLICATION_DATA_DIRECTORY=/openmrs/data/
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.587 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.587 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.587 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.587 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.587 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.637 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.648 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 364 ms
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.665 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.666 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.83]
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.683 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/openmrs.war]
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:48.692 WARNING [localhost-startStop-1] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:52.099 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:30:52,480| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2061) |2023-03-23T17:30:52,485| Unable to find properties file: /openmrs/data/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimeProperties(1994) |2023-03-23T17:30:52,485| Unable to find a runtime properties file. Initial setup is needed. View the webapp to run the setup wizard.
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:30:52,626| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2061) |2023-03-23T17:30:52,627| Unable to find properties file: /openmrs/data/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimeProperties(1994) |2023-03-23T17:30:52,627| Unable to find a runtime properties file. Initial setup is needed. View the webapp to run the setup wizard.
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:52.640 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/openmrs.war] has finished in [3,958] ms
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:52.642 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
openmrs-distro-platform-api-1  | 23-Mar-2023 17:30:52.653 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 4004 ms
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:03,584| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2061) |2023-03-23T17:31:03,585| Unable to find properties file: /openmrs/data/openmrs-runtime.properties
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:04,358| Cannot load service: liquibase.parser.ChangeLogParser: Provider liquibase.parser.core.json.JsonChangeLogParser could not be instantiated
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:04,361| Cannot load service: liquibase.parser.ChangeLogParser: Provider liquibase.parser.core.yaml.YamlChangeLogParser could not be instantiated
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:04,989| Reading from liquibasechangelog
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:05,443| Successfully acquired change log lock
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:05,553| Successfully released change log lock
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:05,685| Reading from liquibasechangelog
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:05,889| Successfully acquired change log lock
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:05,900| Successfully released change log lock
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:06,008| Reading from liquibasechangelog
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:06,061| Successfully acquired change log lock
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:06,069| Successfully released change log lock
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:13,386| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2061) |2023-03-23T17:31:13,386| Unable to find properties file: /openmrs/data/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:13,387| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:13,387| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:13,387| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | INFO - HibernateContextDAO.authenticate(215) |2023-03-23T17:31:13,794| Failed login attempt (login=admin) - Invalid username and/or password: admin
openmrs-distro-platform-api-1  | WARN - Listener.loadBundledModules(571) |2023-03-23T17:31:14,013| Bundled module folder doesn't exist: /usr/local/tomcat/webapps/openmrs/WEB-INF/bundledModules
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:14,014| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(69) |2023-03-23T17:31:14,016| identifying the Liquibase snapshot version that had been used to initialize the OpenMRS database...
openmrs-distro-platform-api-1  | INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(82) |2023-03-23T17:31:14,016| looking for un-run change sets in snapshot version '2.5.x'
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:14,397| Reading from liquibasechangelog
openmrs-distro-platform-api-1  | INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(95) |2023-03-23T17:31:14,606| file 'org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml' contains 0 un-run change sets
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:14,770| Reading from liquibasechangelog
openmrs-distro-platform-api-1  | INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(95) |2023-03-23T17:31:14,971| file 'org/openmrs/liquibase/snapshots/core-data/liquibase-core-data-2.5.x.xml' contains 0 un-run change sets
openmrs-distro-platform-api-1  | WARN - Slf4JLogger.log(41) |2023-03-23T17:31:14,972| Failed to restore the auto commit to true
openmrs-distro-platform-api-1  | INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(113) |2023-03-23T17:31:14,972| the Liquibase snapshot version that had been used to initialize the OpenMRS database is '2.5.x'
openmrs-distro-platform-api-1  | INFO - Slf4JLogger.log(43) |2023-03-23T17:31:15,098| Reading from liquibasechangelog
openmrs-distro-platform-api-1  | INFO - ChangeLogDetective.getUnrunLiquibaseUpdateFileNames(149) |2023-03-23T17:31:15,136| file 'org/openmrs/liquibase/updates/liquibase-update-to-latest-2.6.x.xml' contains 0 un-run change sets
openmrs-distro-platform-api-1  | WARN - Slf4JLogger.log(41) |2023-03-23T17:31:15,137| Failed to restore the auto commit to true
openmrs-distro-platform-api-1  | WARN - ModuleUtil.getModuleRepository(497) |2023-03-23T17:31:15,551| Module repository /openmrs/data/modules doesn't exist.  Creating directories now.
openmrs-distro-platform-api-1  | WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2033) |2023-03-23T17:31:15,563| Unable to find a runtime properties file at /openmrs_core/openmrs-runtime.properties
openmrs-distro-platform-api-1  | WARN - DispatcherServlet.noHandlerFound(1282) |2023-03-23T17:32:14,866| No mapping for GET /openmrs/ws/rest/v1/systeminformation
openmrs-distro-platform-api-1  | WARN - DispatcherServlet.noHandlerFound(1282) |2023-03-23T17:32:22,039| No mapping for GET /openmrs/ws/rest/v1/systeminformation

I think it’s fine, I have the credentials to authenticate myself anyway but thanks for that info!

:man_facepalming: You’re absolutely right! First things first, do you have a copy of the REST module OMOD? If not, you can get it here. Once you have a copy of the OMOD it should be put in the /openmrs/distribution/openmrs_modules directory on the Docker image. You can do that either via a Docker volume, like the way the database.sqlite3 file is passed to the container or via modifying the Docker image you’re using to add that file to the same directory.

Oddly, this is going much better than I expected!

1 Like

I updated the docker-compose.sqlite.yml file on the openmrs-distro-platform repo:

volumes:
  - openmrs-data:/openmrs/data/
  - ${PWD}/sqlite/database.sqlite3:/openmrs/data/database.sqlite3
  - ${PWD}/modules/webservices.rest-2.39.0.omod:/openmrs/distribution/openmrs_modules/webservices.rest-2.39.0.omod

This seems to work fine because I now get result when doing a REST API request although I think mounting the OMOD is the quick and dirty way of doing it - probably not how I’d want to do it someday.

Surprisingly, not having to deal with the Liquibase files made this so much easier. So I’m guessing this is somewhat ready to be tested? How would you suggest I go through testing?

@ibacher I am still quite confused in terms of what each GitHub repo is meant for though, a few things I managed to gather are - although I’m not sure if I understood it correctly:

  • openmrs-core
    • doesn’t come bundled with the REST module
  • openmrs-distro-platform
    • packages the openmrs-core repo?
  • openmrs-distro-referenceapplication
    • packages the gateway, frontend, backend, and database together
    • is this the repo that I would end up needing to modify to use the changes I made and deploy to our servers?

It really depends on what you’re planning to use OpenMRS for. If you want to run the whole RefApp (i.e., the part with a UI), then you would need all the relevant modules for that loaded up. You’d also need a frontend. The 2.x version is supported through modules (see the 2.x branch of the openmrs-distro-referenceapplication repo); the 3.x version uses a single-page application frontend, but you could likely just use the pre-packaged frontend and gateway images. If you’re just looking for a backend platform, then you probably are all set and could try out some of the REST requests suggested in the REST API docs.

Probably a good starting point is this: OpenMRS is “a platform that countries and implementers use to create a customized EMR system in response to needs on the ground.” (taken from our front page). A couple of key points: it’s a platform that can be customised to create an EMR system. Broadly speaking, we provide options.

openmrs-core is the thing that makes something “OpenMRS”. Basically, it’s a Java web application that provides the core data model used throughout OpenMRS applications, Java services for interacting with that data model, and the plumbing that makes our modular architecture work. However, although it’s a webapp, it doesn’t have a user-accessible interface. It’s just a framework.

To customise OpenMRS, we use modules, which are packages of Java code that extend the functionality of OpenMRS in various ways. They might add user interfaces, new models to handle things that are not part of the core data model, or functionality that otherwise enriches OpenMRS.

A package of core and a set of modules is called a “distribution.”

openmrs-distro-platform is a distribution of OpenMRS targeted at projects that want to use the OpenMRS data model with as few “extras” as possible. Basically, it consists of openmrs-core (the main WAR file) plus the REST and FHIR2 modules, which provide web-based APIs for accessing data in openmrs-core. By and large, the platform is intended to be the starting point for distributions that, e.g., want to leverage their own UI or their own set of modules. Roughly speaking, its just the minimum you need.

openmrs-distro-referenceapplication packages a reference application built on top of the same components that make up the platform (though, strictly speaking, it doesn’t embed the platform). Basically, the reference application provides a set of modules that add some additional functionality to OpenMRS (e.g., support for appointments, attachments, reporting, etc.) as well as a UI to use that functionality in a (hopefully) user-friendly way. It’s provided as a starting point for implementations many implementations of OpenMRS, though most implementations are expected to take the reference application and further customise it to suit their specific needs.

2 Likes

Thank you very much for explaining this :heart:. I think I now have a better understanding of what those repos are about.

Our plan is to install OpenMRS 3 (backend, frontend, and I believe gateway would be required as well) so essentially we’d be installing the openmrs-distro-referenceapplication on each of the facilities we provide services to. The only difference is that it would be running on top of a SQLite database instead of MySQL.

Based on the way you described openmrs-distro-platform above, I’m under the impression that it doesn’t have all of the modules we need for what we plan on achieving.

Right now my mind is telling me that I would need to replace the openmrs/openmrs-reference-application-3-backend:${TAG:-nightly} image being used for the RefApp repo with a custom image that we will build ourselves that includes pretty much all of the modules on the original image but also has the changes needed to connect to a SQLite db. Does this sound like the correct direction?

Yes, it does. Though if you get this working, we should look into getting the relevant changes into openmrs-core (and wherever else) so you can just use our default images.

Agreed, but let’s look into this when things are stable.

I tried running a bunch of GET API requests which all seemed to work fine without any errors. But when I tried to do a POST request to add a new patient:

POST /patient
{
   "identifiers":[
      {
         "identifier":"103VWY7",
         "identifierType":"71075074-f02e-4270-89a3-f2dcda436f70",
         "location":"9356400c-a5a2-4532-8f2b-2361b3446eb8",
         "preferred":true
      }
   ],
   "person":{
      "gender":"M",
      "age":47,
      "birthdate":"1970-01-01T00:00:00.000+0100",
      "birthdateEstimated":false,
      "dead":false,
      "deathDate":null,
      "causeOfDeath":null,
      "names":[
         {
            "givenName":"Thomas",
            "familyName":"Smith"
         }
      ],
      "addresses": [
        {
        "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
        "cityVillage": "Bengaluru",
        "country": "India",
        "postalCode": "560037"
        }
      ]
    }
}

I got the following error:

{
    "error": {
        "message": "[identifiers on class org.openmrs.Patient => identifierType on class org.openmrs.PatientIdentifier]",
        "code": "org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource:800",
        "detail": "org.openmrs.module.webservices.rest.web.response.ConversionException: identifiers on class org.openmrs.Patient\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:800)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setConvertedProperties(BaseDelegatingResource.java:671)\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8.getPatient(PatientResource1_8.java:242)\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8.create(PatientResource1_8.java:222)\n\tat org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.create(MainResourceController.java:91)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:682)\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:765)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:73)\n\tat org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:65)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:121)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.webservices.rest.web.filter.ContentTypeFilter.doFilter(ContentTypeFilter.java:64)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:106)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:57)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.owasp.csrfguard.CsrfGuardFilter.handleSession(CsrfGuardFilter.java:107)\n\tat org.owasp.csrfguard.CsrfGuardFilter.doFilter(CsrfGuardFilter.java:97)\n\tat org.owasp.csrfguard.CsrfGuardFilter.doFilter(CsrfGuardFilter.java:68)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:114)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.openmrs.web.filter.CookieClearingFilter.doFilterInternal(CookieClearingFilter.java:77)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.springframework.orm.hibernate5.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:156)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:125)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:111)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:111)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:111)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\n\tat org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:367)\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:639)\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:885)\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1693)\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n\tat org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)\n\tat org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:750)\nCaused by: org.openmrs.module.webservices.rest.web.response.ConversionException: identifierType on class org.openmrs.PatientIdentifier\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:800)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convertMap(ConversionUtil.java:322)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:272)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:213)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:786)\n\t... 91 more\nCaused by: java.lang.reflect.InvocationTargetException\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:787)\n\t... 95 more\nCaused by: java.lang.NullPointerException\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientIdentifierResource1_8.setIdentifierType(PatientIdentifierResource1_8.java:100)\n\t... 100 more\n"
    }
}

Could you just try with:

{
   "person":{
      "gender":"M",
      "age":47,
      "birthdate":"1970-01-01T00:00:00.000+0100",
      "birthdateEstimated":false,
      "dead":false,
      "deathDate":null,
      "causeOfDeath":null,
      "names":[
         {
            "givenName":"Thomas",
            "familyName":"Smith"
         }
      ],
      "addresses": [
        {
        "address1": "30, Vivekananda Layout, Munnekolal,Marathahalli",
        "cityVillage": "Bengaluru",
        "country": "India",
        "postalCode": "560037"
        }
      ]
    }
}

Basically, remove the identifiers part (the identifiers part relies on you having some metadata set up, including identifierType and location and so far, I don’t think you have any).

This is what I got with that request:

"message": "[Some required properties are missing: identifiers]"

I also tried:

"identifiers": [
    {
        "identifier": "103VWY7",
        "preferred": true
    }
],

and

"identifiers": [],

But got the following error for both:

"message": "Invalid Submission"

Could you try just creating a Person rather than a Patient? Otherwise, we’d need to first create an identifier type. The endpoint is /person instead of /patient and the body can just be what you have in the person key of the JSON above.

I was able to create a Person with no issues and every other endpoints I’ve tested seems to have worked. Is it safe to assume that the REST API is fine and we can start packaging everything together?

Yes, that’s great news! It means we’ve got some basic functionality working. Things will get a little more complex as we add more modules, since, unlike the REST API, many of those modules have their own liquibase changes, mostly to add tables that they need, but yes, let’s see how far this can get!

In terms of the backend modules, I believe here’s what we want included (commented out the ones we think we don’t need):

omod.initializer=${initializer.version}
omod.fhir2=${fhir2.version}
omod.webservices.rest=${webservices.rest.version}
omod.idgen=${idgen.version}
# omod.legacyui=${legacyui.version}
omod.addresshierarchy=${addresshierarchy.version}
omod.metadatamapping=${metadatamapping.version}
omod.metadatasharing=${metadatasharing.version}
omod.openconceptlab=${openconceptlab.version}
omod.owa=${owa.version}
# omod.referencedemodata=${referencedemodata.version}
omod.attachments=${attachments.version}
omod.queue=${queue.version}
# omod.appointments=${appointments.version}
# omod.appointments.groupId=org.bahmni.module
omod.cohort=${cohort.version}
# omod.reporting=${reporting.version}
# omod.reportingrest=${reportingrest.version}
omod.calculation=${calculation.version}
# omod.htmlwidgets=${htmlwidgets.version}
omod.serialization.xstream=${serialization-xstream.version}
omod.serialization.xstream.type=omod
omod.ordertemplates=${ordertemplates.version}

Do you have any general guides like you gave me about all the changes I needed to make that I can follow on how to package all of these together? I’ve been trying but my lack of experience with Docker is making it difficult for me to really understand what’s happening.

You should also be able to get rid of calculation and the serialization.xstream ones. Those are part of the distro to support the reporting module. I also think owa can be omitted.

Here’s the Dockerfile we use to build the backend image in the RefApp:

# syntax=docker/dockerfile:1

### Dev Stage
FROM openmrs/openmrs-core:dev as dev
WORKDIR /openmrs_distro

ARG MVN_ARGS_SETTINGS="-s /usr/share/maven/ref/settings-docker.xml -U"
ARG MVN_ARGS="install"

# Copy build files
COPY pom.xml ./
COPY distro ./distro/

# Build the distro
RUN --mount=type=secret,id=m2settings,target=/root/.m2/settings.xml mvn $MVN_ARGS_SETTINGS $MVN_ARGS

RUN cp /openmrs_distro/distro/target/sdk-distro/web/openmrs.war /openmrs/distribution/openmrs_core/

RUN cp /openmrs_distro/distro/target/sdk-distro/web/openmrs-distro.properties /openmrs/distribution/
RUN cp -R /openmrs_distro/distro/target/sdk-distro/web/modules /openmrs/distribution/openmrs_modules
RUN cp -R /openmrs_distro/distro/target/sdk-distro/web/owa /openmrs/distribution/openmrs_owas

# Clean up after copying needed artifacts
RUN mvn clean $MVN_ARGS_SETTINGS

### Run Stage
# Replace 'nightly' with the exact version of openmrs-core built for production (if available)
FROM openmrs/openmrs-core:nightly

# Do not copy the war if using the correct openmrs-core image version
COPY --from=dev /openmrs/distribution/openmrs_core/openmrs.war /openmrs/distribution/openmrs_core/

COPY --from=dev /openmrs/distribution/openmrs-distro.properties /openmrs/distribution/
COPY --from=dev /openmrs/distribution/openmrs_modules /openmrs/distribution/openmrs_modules
COPY --from=dev /openmrs/distribution/openmrs_owas /openmrs/distribution/openmrs_owas
COPY --from=dev /openmrs_distro/distro/configuration /openmrs/distribution/openmrs_config

It’s broken up into two stages:

  1. A Dev Stage
  2. A Run Stage

The dev stage basically runs Maven to package up the distribution and then copies the files we need from it to locations on that image. The Run stage creates a new image from our base image and then copies the WAR file, modules, and configuration to the correct place. Notice the COPY --from=dev commands and the first non-comment line names “openmrs/openmrs-core:dev” “dev”.

Now, if you run build on that image it will build it without the custom WAR. So I would:

  1. Go back to the original docker-compose we were using and set things up so the tag for the image is something distinctive, e.g. openmrs/openmrs-core:sqlite
  2. In the Dockerfile for the referenceapplication distro, change FROM openmrs/openmrs-core:nightly to FROM openmrs/openmrs-core:sqlite
  3. Remove this line: COPY --from=dev /openmrs/distribution/openmrs_core/openmrs.war /openmrs/distribution/openmrs_core/ as the image already should have the version of the OpenMRS WAR we want to use.

That should probably do it.

Okay so here’s what I did:

openmrs-core

  • docker-compose.override.yml
  • docker-compose.sqlite.yml
  • docker-compose.yml

Modified the files above to use the openmrs/openmrs-core:${TAG:-sqlite} image. I also removed the mounting of the SQLite database from this repo because I think that should be done on the RefApp side. Let me know if that’s wrong.

I then ran:

docker compose build --build-arg MVN_ARGS='install -DskipTests'

This created the openmrs-core:sqlite image.

openmrs-distro-referenceapplication

Made the changes you outlined above regarding the Dockerfile changes.

I then added a docker-compose.sqlite.yml file:

version: "3.7"

services:
  gateway:
    image: openmrs/openmrs-reference-application-3-gateway:${TAG:-nightly}
    depends_on:
      - frontend
      - backend
    ports:
      - "80:80"

  frontend:
    image: openmrs/openmrs-reference-application-3-frontend:${TAG:-nightly}
    environment:
      SPA_PATH: /openmrs/spa
      API_URL: /openmrs
      SPA_CONFIG_URLS:
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/"]
      timeout: 5s
    depends_on:
      - backend

  backend:
    image: openmrs/openmrs-core:${TAG:-sqlite}
    environment:
      OMRS_CONFIG_MODULE_WEB_ADMIN: "true"
      OMRS_CONFIG_AUTO_UPDATE_DATABASE: "true"
      OMRS_CONFIG_CREATE_TABLES: "true"

      OMRS_CONFIG_DB_DRIVER_CLASS: ${OMRS_DB_DRIVER_CLASS:-org.sqlite.JDBC}
      OMRS_CONFIG_DB_URL: ${OMRS_DB_URL:-jdbc:sqlite:/openmrs/data/database.sqlite3}
      OMRS_CONFIG_HIBERNATE_DIALECT: ${OMRS_HIBERNATE_DIALECT:-org.sqlite.hibernate.dialect.SQLiteDialect}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/openmrs"]
      timeout: 5s
    volumes:
      - openmrs-data:/openmrs/data
      - ${PWD}/sqlite/database.sqlite3:/openmrs/data/database.sqlite3

volumes:
  openmrs-data: ~

This should use the new image I just built (openmrs-core:sqlite) with the JDBC driver and the SQLite dialect for the backend. This should also mount the local SQLite database.

I then ran:

docker compose -f docker-compose.sqlite.yml up -d

This starts up a set of new containers. The logs for the openmrs-distro-referenceapplication-backend-1 container does however shows this:

2023-03-28 12:44:25 WARN - InitializationFilter.verifyConnection(987) |2023-03-28T18:44:24,998| Error while checking the connection user account
2023-03-28 12:44:25 java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
2023-03-28 12:44:25     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:898) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_362]
2023-03-28 12:44:25     at org.openmrs.web.filter.initialization.InitializationFilter.verifyConnection(InitializationFilter.java:977) [openmrs-web-2.7.0-SNAPSHOT.jar:?]
2023-03-28 12:44:25     at org.openmrs.web.filter.initialization.InitializationFilter.access$400(InitializationFilter.java:80) [openmrs-web-2.7.0-SNAPSHOT.jar:?]
2023-03-28 12:44:25     at org.openmrs.web.filter.initialization.InitializationFilter$InitializationCompletion$1.run(InitializationFilter.java:1495) [openmrs-web-2.7.0-SNAPSHOT.jar:?]
2023-03-28 12:44:25     at java.lang.Thread.run(Thread.java:750) [?:1.8.0_362]
2023-03-28 12:44:25 Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
2023-03-28 12:44:25 
2023-03-28 12:44:25 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2023-03-28 12:44:25     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_362]
2023-03-28 12:44:25     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_362]
2023-03-28 12:44:25     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_362]
2023-03-28 12:44:25     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.NativeSession.connect(NativeSession.java:120) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:842) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     ... 10 more
2023-03-28 12:44:25 Caused by: java.net.ConnectException: Connection refused (Connection refused)
2023-03-28 12:44:25     at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_362]
2023-03-28 12:44:25     at java.net.Socket.connect(Socket.java:607) ~[?:1.8.0_362]
2023-03-28 12:44:25     at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:153) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.NativeSession.connect(NativeSession.java:120) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:842) ~[mysql-connector-java-8.0.30.jar:8.0.30]
2023-03-28 12:44:25     ... 10 more

Any ideas?

This should be OMRS_DB_URL or OMRS_CONFIG_CONNECTION_URL

I did see some references to environment variables:

  • OMRS_CONFIG_MODULE_WEB_ADMIN / OMRS_MODULE_WEB_ADMIN
  • OMRS_CONFIG_AUTO_UPDATE_DATABASE / OMRS_AUTO_UPDATE_DATABASE
  • OMRS_CONFIG_CREATE_TABLES / OMRS_CREATE_TABLES

So what I did was be consistent with it so I added the _CONFIG in there. Anyway, I reverted the names of the new environment variables:

  • OMRS_DB_DRIVER_CLASS
  • OMRS_DB_URL
  • OMRS_HIBERNATE_DIALECT

I then recreated the the containers:

docker compose -f docker-compose.sqlite.yml up -d

And got these:

2023-03-28 13:32:44 org.openmrs.util.DatabaseUpdateException: There was an error while updating the database to the latest. file: org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml. Error: Validation Failed:
2023-03-28 13:32:44      420 changes have validation failures
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-662::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-663::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-664::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-665::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-666::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-667::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-668::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-669::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-670::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-671::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-672::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-673::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-674::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-675::danielkayiwa (generated)
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/snapshots/schema-only/liquibase-schema-only-2.5.x.xml::1644357630219-676::danielkayiwa (generated)

...

2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/updates/liquibase-update-to-latest-2.6.x.xml::TRUNK-6071-20220406::PIH
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/updates/liquibase-update-to-latest-2.6.x.xml::TRUNK-6071-20220406::PIH
2023-03-28 13:32:44           addForeignKeyConstraint is not supported on sqlite, org/openmrs/liquibase/updates/liquibase-update-to-latest-2.6.x.xml::TRUNK-6071-20220406::PIH
2023-03-28 13:32:44           addNotNullConstraint is not supported on sqlite, org/openmrs/liquibase/updates/liquibase-update-to-latest-2.6.x.xml::TRUNK-6081-2022-11-21::wikumChamith
2023-03-28 13:32:44 
2023-03-28 13:32:44     at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:299) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Liquibase$16.run(Liquibase.java:1987) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Scope.lambda$child$0(Scope.java:166) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Scope.child(Scope.java:175) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Scope.child(Scope.java:165) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Scope.child(Scope.java:144) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Liquibase.runInScope(Liquibase.java:2404) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Liquibase.listUnrunChangeSets(Liquibase.java:1977) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at liquibase.Liquibase.listUnrunChangeSets(Liquibase.java:1968) ~[liquibase-core-4.4.3.jar:?]
2023-03-28 13:32:44     at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:217) ~[openmrs-api-2.7.0-SNAPSHOT.jar:?]
2023-03-28 13:32:44     at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:188) ~[openmrs-api-2.7.0-SNAPSHOT.jar:?]
2023-03-28 13:32:44     ... 2 more

Is this no longer the same SQLite database that was migrated from MySQL?