Error saving diagnosis in clinical note

Hi there, I am running the Reference Application version 2.12.2 with MySQL 8.0.37.

When creating a clinical note and entering a diagnosis, the UI displays an “Unexpected Error” (see screenshot). Looking into the application logs, I see a variety exceptions, an interesting one being "Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank) values " In my investigation, I found that ‘rank’ is a field of a Diagnosis, and that RANK was introduced as a keyword in MySQL version 8, which explains why the application threw an error.

From the implementer documentation regarding installation of MySQL, I found that “OpenMRS Platform version 2.4 and above support MySQL 8”, and from the 2.12.0 release notes I found that this version of the refapp is built on platform version 2.4.0, so I would have expected my version of the app to be compatible with MySQL 8.

So I am wondering if anyone has encountered this issue before, and if there is a workaround that doesn’t involve downgrading MySQL?

Application logs are here: catalina.out_clinical_note - Google Drive

You can upgrade the underlying platform version to 2.5.0

https://openmrs.atlassian.net/browse/TRUNK-6044

Thank you Daniel!

If I installed the application using the Ref App 2.12.2 WAR, how would I go about updating the platform version?

Wondering if this is a properties change where I can just update the platform version, if I will need to install the new platform WAR, if I need to update my version of the RefApp entirely, or some other process.

Is there a reason why you do just run reference application version 2.13.0 which has a newer version of the platform?

I initially tried to set up version 2.13.0 of the ref app, but could not manage to get the application to start up, it wouldn’t even load up the installation wizard.

The error was Caused by: org.openmrs.api.APIException: '{0}' should be a directory but it is not

I had thought it was a permissions issue but no configuration of permissions seemed to work, I tried setting tomcat as the owner of the application data directory and updating tomcat’s readWritePaths. Using version 2.12.2 I didn’t have this problem

It would help to see the full server side log via something like pastebin.com

Here is the log file: refapp 2.13.0 startup error - Pastebin.com

any advice on this issue? digging a little deeper into the stacktrace and trying to follow along in the code, I found that this getConfigurationFiles() method is called, which then calls out to OpenmrsUtil.getDirectoryInApplicationDataDirectory(“configuration”), where we run into the “should be a directory but is not” issue.

So it seems to be looking for a configuration directory within the application data directory. I specify a custom application data directory in my runtime properties file, and have made sure that tomcat user has read/write access. The configuration directory was not auto-created within the app data directory that I specify, so I also tried creating the configuration directory manually, but that didn’t seem to make a difference on restart.

I notice the log specifies '{0}' should be a directory but it is not where {0} seems to be the result of folder.getAbsolutePath(), but this is not an actual path. Could the application be trying to reference a different application data directory, perhaps the default location when a custom directory is not specified in the runtime properties?

Because you speak like a developer, have you tried out the SDK? https://openmrs.atlassian.net/wiki/spaces/docs/pages/25476136/OpenMRS+SDK

I have seen docs regarding the SDK, but I’m not sure how that will help me here as I’m not trying to develop a module, just trying to deploy the 2.13.0 reference application

Just for troubleshooting purposes, are you able to set up the reference application while using the SDK?

Sorry for the delay, just got the opportunity today to start setting up the SDK. I’ve got the sdk installed and dependencies set up, except for MySQL. I see in the link you sent that " Servers can be configured to use H2 or MySQL 5.7 database."

If I use a MySQL 5.7 database, then I wouldn’t really be replicating the same environment I’m trying to use when deploying the 2.13.0 refapp, so I would not be able to troubleshoot under the same circumstances. Will the SDK work if I use MySQL 8?

From MySQL 5.7 and above. So yes it will work with MySQL 8

Hi Daniel, I was able to get RefApp 2.13.0 running locally using the SDK with no issues on startup. I was able to validate that the initial issue of not being able to save a diagnosis in a clinical note is fixed with this version of the reference application.

On to the issue I’ve been having with deploying this version of the reference application to my actual environment, I used the all same dependencies as in that other environment, so the only difference should be the OS the application is running on(Ubuntu 22.04) .

Do you have any recommendations for me to further troubleshoot? Is it possible to run a virtual environment or container with Ubuntu 22.04, and use the SDK from there?

A full server side log for the RefApp 2.13.0 would be a good starting point.

The server-side logs for deploying 2.13.0 to my actual environment are linked above, but here they are again: refapp 2.13.0 startup error - Pastebin.com

The logs I get from deploying 2.13.0 locally via SDK are here: 2.13.0_local_openmrs.log - Google Drive