I was just trying to set up a new instance of the PIH EMR using the SDK, and it failed during the liquibase updates. We are currently using OpenMRS 2.3.4-SNAPSHOT, so I tried setting up just a 2.3.4-SNAPSHOT instance (ie during SDK setup I chose “Platform” and then manually entered version “2.3.4-SNAPSHOT”) and I’m getting the same error during startup while trying to run the liquibase changesets:
EVERE 11/19/21 10:06 AM:liquibase: Change Set liquibase-update-to-latest.xml::20120504-1020::raff failed. Error: Migration failed for change set liquibase-update-to-latest.xml::20120504-1020::raff:
Reason:
liquibase-update-to-latest.xml : Empty result set, expected one row
:
Caused By: Precondition Error
liquibase.exception.MigrationFailedException: Migration failed for change set liquibase-update-to-latest.xml::20120504-1020::raff:
Reason:
liquibase-update-to-latest.xml : Empty result set, expected one row
:
Caused By: Precondition Error
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:285)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at org.openmrs.util.DatabaseUpdater$1OpenmrsUpdateVisitor.visit(DatabaseUpdater.java:191)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:220)
at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:150)
at org.openmrs.web.filter.initialization.InitializationFilter$InitializationCompletion$1.run(InitializationFilter.java:1644)
at java.lang.Thread.run(Thread.java:748)
Caused by: liquibase.exception.PreconditionErrorException: Precondition Error
at liquibase.precondition.core.PrimaryKeyExistsPrecondition.check(PrimaryKeyExistsPrecondition.java:54)
at liquibase.precondition.core.NotPrecondition.check(NotPrecondition.java:30)
at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:34)
at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:199)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:249)
... 7 more
What’s odd is that there are no recent changes to the liquibasechangesets as far as I can see. And this changeset appears to be failing because the “drug_ingredient” table doesn’t exist. Looking at the liquibase history I see that the prior two changesets did run:
20120504-1000 Dropping the drug_ingredient table 10495 2021-11-19 10:06:21 EXECUTED
20120504-1010 Creating the drug_ingredient table 10496 2021-11-19 10:06:21 MARK_RAN
But note that “20120504-1000” appears to run successfully (and drops the drug_ingredient table) but then the one that recreates the table is “marked as run”, which should only else if the table exists.
No dice… for some reason it appears that that change set to create the “drug ingredient” tables gets marked as run even though the table doesn’t seem to exist.
I confirmed the same thing happened when I try to set up platform 2.3.3.
Bizarre, because nothing should have changed there recently… I’m guessing that something was tweaked recently with the starter database the SDK imports to cause the problem?
I see the same behavior locally, so this isn’t something just with your dev environment @mogoodrich . The error seems to imply that a changeset is empty:
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set liquibase-update-to-latest.xml::20120504-1020::raff:
Reason:
liquibase-update-to-latest.xml : Empty result set, expected one row
@ibacher is this related to the latest SDK release that went out?
BTW, with the latest SDK, I get this weird message:
Caused By: Precondition Error
liquibase.exception.MigrationFailedException: Migration failed for change set liquibase-update-to-latest.xml::20120504-1020::raff:
Reason:
liquibase-update-to-latest.xml : Table '2_3_4_test.address_hierarchy_address_to_entry_map' doesn't exist
:
Caused By: Precondition Error
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:285)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at org.openmrs.util.DatabaseUpdater$1OpenmrsUpdateVisitor.visit(DatabaseUpdater.java:191)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:220)
at org.openmrs.util.DatabaseUpdater.executeChangelog(DatabaseUpdater.java:150)
at org.openmrs.web.filter.initialization.InitializationFilter$InitializationCompletion$1.run(InitializationFilter.java:1644)
at java.lang.Thread.run(Thread.java:748)
Caused by: liquibase.exception.PreconditionErrorException: Precondition Error
at liquibase.precondition.core.PrimaryKeyExistsPrecondition.check(PrimaryKeyExistsPrecondition.java:54)
at liquibase.precondition.core.NotPrecondition.check(NotPrecondition.java:30)
at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:34)
at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:199)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:249)
... 7 more
@ibacher interesting… using “mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:4.1.1:run” things work… and note that they even if I set up with 4.2.0, ie if I run
I had assumed that something had gone wrong during the setup, but it looks like something else. Did we change how OpenMRS connects to the DB between 4.1.1. and 4.2.0? Looks like we upgraded from Tomcat 7 to 9, any chance that could be the problem?
That seems like a likely culprit. I managed to get 4.1.1 working here and saw the same thing. Let me try reverting to Tomcat 7 and see if things work.
The other possible culprit is that the SDK has a version of the MySQL connector on the classpath and with 4.2.0, this is now using MySQL/J 8. It’s possible that that’s returning metadata that the very old version of Liquibase in 2.3.x doesn’t understand.
Ok, it’s definitely the MySQL thing, which is my least favourite option, because it probably means doing some sort of classpath jujitsu…
The challenge here is that we need a newer version of the MySQL library to be able to setup platform 2.4+, but we’ll need the older version for platform 2.3-. The easiest thing is if we can change the Tomcat runner to not use the embedded Tomcat… or at least to do so in a new JVM.
Alright, I have a strategy for this, though it involves some refactoring parts of the SDK, but the SDK already needs that as parts of business logic are all over the place in various helper classes that aren’t always well thought-through or organised.
The plan is this: We already have the capability of starting Tomcat in a forked Maven instance. By itself, this doesn’t help much because the Tomcat running component is still part of the full SDK and so it also includes the “bad” version of the MySQL connector on it’s classpath. So I’m going to refactor things so that the Tomcat Mojo is independent of the rest of the SDK, which should allow us to run things in Tomcat without pre-polluting the classpath. That should fix this issue, but it might take a bit to implement, especially with Thanksgiving next week.
Awesome, thanks @ibacher and @mogoodrich . Let me know if I or others can help with this in any way. On a related note, I’d be interested in brainstorming whether any future might exist where we either support or transition to Docker for Tomcat as a replacement or alternative to the embedded server. This would provide us a lot of potential flexibility around supporting different Java/Tomcat versions (eg. the image as input argument), and would also get us closer to simulating actual running server environments. Interested in thoughts.
Thanks @ibacher ! I’m not super familiar with the SDK so don’t really understand the issue, but I trust you… this is something that just shows up in the context of the SDK, correct?
I’d also be in support of looking into Apache via Docker.
Currently, I can not get even 4.1.1 working, the server keeps complaining that it can not create a connection to the database server even when all the connection properties are set clearly. I am using Mysql 5.7 and use the command mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:4.1.1:setup -Ddistro=org.openmrs.module:ugandaemr:LATEST-SNAPSHOT to create a server.
Yes. The problem is roughly that we’re loading Tomcat (and thus OpenMRS) using the current classloader that’s running the SDK as the parent classloader, so classes already registered are the copies from the SDK rather than OpenMRS. This shouldn’t affect anything that isn’t running the SDK explicitly.
This has my complete support! Docker would be a much cleaner solution in many ways.
If you can provide the SDK output (preferably on something like pastebin.com or a gist or something), it would be helpful in troubleshooting things. For me, the command you listed works just fine with MySQL 5.7, but I run my MySQL instances as Docker containers locally.
There are many non-Docker users, and surveying those around Uganda I will tell you that the power of the machines + Internet connectivity would be a blocker (we pay for data by the MB)
Yesterday I think I had the same issue when I was deploying one of my trial spring projects.
Error ( . For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.)
Solution: Look for the DB properties and change the mysql url useSSL to false
Example:
mysql.url=jdbc:mysql://localhost:3306/test?useSSL=false