initial dev setup problem

One more thing, after the initialisation could you please check the current state of your MySQL database:

$ mysql -u root -p

mysql> show databases; – the resulting list should contain ‘openmrs’

mysql> use openmrs;

mysql> show tables; – should list all OpenMRS tables

Thanks, Wolf

I have done that exact sequence (completely starting over) several times in the last few days. Here is a folder on my google drive with (1) server log, (2) screen capture of browser, (3) mysql tables list.

Thanks.

Thanks for the update and apologies for the inconvenience you are experiencing, Lee.

I went through the log and compiled a condensed version:

[INFO] Scanning for projects...
Downloading from openmrs-repo: https://mavenrepo.openmrs.org/nexus/content/repositories/public/javax/annotation/javax.annotation-api/maven-metadata.xml
Progress (1): 591 B

Downloaded from openmrs-repo: https://mavenrepo.openmrs.org/nexus/content/repositories/public/javax/annotation/javax.annotation-api/maven-metadata.xml (591 B at 262 B/s)
[INFO]
[INFO] -------------------< org.openmrs.web:openmrs-webapp >-------------------
[INFO] Building openmrs-webapp 2.4.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO]
...
Line 89 >>>> INFO - Slf4jLogger.info(42) |2020-05-22T05:56:41,874| CREATE TABLE openmrs.liquibasechangelog (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED datetime NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35) NULL, `DESCRIPTION` VARCHAR(255) NULL, COMMENTS VARCHAR(255) NULL, TAG VARCHAR(255) NULL, LIQUIBASE VARCHAR(20) NULL, CONTEXTS VARCHAR(255) NULL, LABELS VARCHAR(255) NULL, DEPLOYMENT_ID
...
Line 96 >>>> INFO - Slf4jLogger.info(42) |2020-05-22T05:56:46,095| CREATE TABLE openmrs.liquibasechangeloglock (ID INT NOT NULL, `LOCKED` TINYINT(1) NOT NULL, LOCKGRANTED datetime NULL, LOCKEDBY VARCHAR(255) NULL, CONSTRAINT PK_LIQUIBASECHANGELOGLOCK PRIMARY KEY (ID))
...
Line 105 >>>> INFO - Slf4jLogger.info(42) |2020-05-22T05:56:48,966| ChangeSet org\openmrs\liquibase\snapshots\schema-only\liquibase-schema-only-2.3.x.xml::1582473628795-1::wolf (generated) ran successfully in 110ms
...
Line 3615 >>>> INFO - Slf4jLogger.info(42) |2020-05-22T05:58:22,234| ChangeSet org\openmrs\liquibase\snapshots\core-data\liquibase-core-data-2.3.x.xml::1582473679024-17::wolf (generated) ran successfully in 20ms
...
Line 4789 >>>> [INFO] Initializing Spring root WebApplicationContext
...
Line 4798 >>>> INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(80) |2020-05-22T05:58:48,415| looking for un-run change sets in snapshot version '2.3.x'
...
Line 4805 >>>> INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(89) |2020-05-22T05:58:50,053| file 'org\openmrs\liquibase\snapshots\schema-only\liquibase-schema-only-2.3.x.xml' contains 875 un-run change sets
...
Line 4812 >>>> INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(89) |2020-05-22T05:58:50,572| file 'org\openmrs\liquibase\snapshots\core-data\liquibase-core-data-2.3.x.xml' contains 25 un-run change sets
...

The first four entries marked by “>>>>” show that the database was successfully initialised based on the 2.3.x Liquibase snapshots (which is good and as expected).

Line 4789 signals that initialisation is over and the web application is initialised.

The last three entries show that the 2.3.x snapshots are not being recognised (which is bad) and we need to figure out why that is the case.

Could you please share the result of running these commands:

$ mysql -u root -p
mysql> use openmrs;
mysql> describe liquibasechangelog;
mysql> select * from liquibasechangelog;

Could you please also share the link to the Google doc folder containing all documents? I could open the log file but not the other files you had shared.

Thank you, Wolf

oops, sorry about the gdrive link, try this: https://drive.google.com/open?id=1btjJGwZDrPNeqP5YOMbeGfP0g6Gt2UF2

I added openmrs-mysql.txt which has the output of the two commands.

Thanks, Lee, the mysql output looks as expected.

The next step is a debugging session, which IDE are you using please?

I am using IntelliJ Community Edition, we need to debug what is going in in Liquibase when looking for un-run change sets.

I would prepare a dry run on my side to find the places where to set the breakpoints and would then share the recipe with you.

Is that ok for you?

sure, I’m an experienced java developer. I use eclipse. we can do a webex meeting if you’d like…

here’s another thought: maybe I should delete my git workspace and refetch it from scratch – maybe I have some file that’s corrupted?

You could try that but I the failure seems to “orderly” if that makes sense.

Are you running mvn from the console or from Eclipse?

I have been running from console, but I just went into eclipse and set it up to debug the mvn jetty:run. In fact, I’m in org.openmrs.liquibase.ChangeLogDetective.getInitialLiquibaseSnapshotVersion, but ofc I don’t know what I’m looking for…

Also, I signed on to the irc channel if you want to chat there.

I am close to finishing the debugging dry runs, which time zone are you in pls?

I am based in Ratingen, Germany.

west coast of USA

I am good to go, would OpenMRS slack work as well?

sure slack is fine. let me find it…

@dkayiwa @leebreisacher and I had a debugging session today and the root cause is that Liquibase uses backslashes on Windows where it should not. This leads to change sets not being recognised.

The error materialised with 2.4.0-SNAPSHOT since I moved the snapshot files into resource packages (before the files were located directly in the resources directory).

I raise an error ticket with Liquibase and Lee most likely moves to a Linux VM for the time being.

1 Like

@leebreisacher I am working on a pull request for liquibase, could you please give https://github.com/WolfSchlegel/liquibase/tree/OpenMRS-TRUNK-4830 a try?

I went for a very targeted fix where I changed the ValidatingVisitor class only as ChangeLog#toString(boolean) is used in many places.

You would need to build the Liquibase branch locally and update the liquibase version in openmrs-core:

  • replace 3.8.9 with 3.8.10-local-SNAPSHOT in <somewhere>/openmrs-core/pom.xml

Please let me know if that fixes the backslash issue during the initialisation of OpenMRS on a Windows machine.

If so I create a pull request for Liquibase and you would have a local fix until the pull request is merged.

Thanks, Wolf

That fix does not work. Recall the keys in the ‘ranIndex’ map have backslashes (on my Windows system), and the changeSet parameter has forward slashes. So, sorry to say, your fix does not actually do anything :wink:

Just to verify, I tried changing your fix to the other way around (.replace("/","\")) (which is obviously not a proper fix as it would break on linux), but that didn’t seem to fix it either. I’ve set breakpoints and looked around and I don’t quite (yet) see why it is not working. Still digging…

I stepped through ValidatingVisitor>findChangeSet and indeed it appears to be working correctly when I use replace("/", “\”), but I still get this in the log: INFO - ChangeLogDetective.getInitialLiquibaseSnapshotVersion(89) |2020-05-23T07:45:22,420| file ‘org\openmrs\liquibase\snapshots\core-data\liquibase-core-data-1.9.x.xml’ contains 23 un-run change sets Exception in thread “Thread-16” org.openmrs.module.ModuleException: Unable to start OpenMRS. Error thrown was: Should not be here because updates were run previously at org.openmrs.web.WebDaemon.startOpenmrs(WebDaemon.java:64) at org.openmrs.web.filter.initialization.InitializationFilter$InitializationCompletion$1.run(InitializationFilter.java:1733) at java.lang.Thread.run(Thread.java:748) Caused by: javax.servlet.ServletException: Should not be here because updates were run previously at org.openmrs.web.Listener.startOpenmrs(Listener.java:235) at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42) Caused by: org.openmrs.util.DatabaseUpdateException: Unable to check if database updates are required at org.openmrs.api.context.Context.checkForDatabaseUpdates(Context.java:1170) at org.openmrs.api.context.Context.startup(Context.java:879) at org.openmrs.web.Listener.startOpenmrs(Listener.java:232) … 1 more Caused by: java.lang.IllegalStateException: identifying the snapshot version that had been used to initialize the OpenMRS database failed as no candidate change set resulted in zero un-run changes at org.openmrs.liquibase.ChangeLogDetective.getInitialLiquibaseSnapshotVersion(ChangeLogDetective.java:102) at org.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:591) at org.openmrs.util.DatabaseUpdater.updatesRequired(DatabaseUpdater.java:270) at org.openmrs.api.context.Context.checkForDatabaseUpdates(Context.java:1167) … 3 more

I don’t understand…

Apologies for the fake fix, I was thinking the wrong way round. Working on a better one right now, I simulate Windows by changing selected filenames in the liquibasechangelog table to use backslashes.

Hi Lee,

I fixed the fix, the second version is available under https://github.com/WolfSchlegel/liquibase/tree/OpenMRS-TRUNK-4830.

There are four places in the codebase where paths are normalised and I replaced backslashes with forward slashes there.

To test this locally, I simulated Windows by modifying one record in the liquibasechangelog table to contain backslashes in the filename field. When starting OpenMRS, this record is recognised as being run before despite the mismatching slashes (which is the desired result).

Please give it another try. If this fix does not work on a real Windows environment, I am prepared to strike the sails and just report the bug to Liquibase (as opposed to submitting a fix).

Thanks, Wolf

That fixed it. Thanks!

But next I tried installing just the legacyui module and got some strange error. So then I tried the entire pile of refapp modules from https://ci.openmrs.org/browse/REFAPP-OMODDISTRO-9905/artifact and it gets all done starting up (takes quite some time) then I get this error: org.openmrs.module.ModuleException: Unable to start OpenMRS. Error thrown was: org.openmrs.api.APIException: Service not found: interface org.openmrs.scheduler.SchedulerService

I’ll continue trying things…