Unable to build/package openmrs-standalone for Reference Application

Tags: #<Tag:0x00007f0a35835478>

When doing a mvn clean package -Dopenmrs.version=2.2 on the openmrs_emr branch of openmrs-standalone I am facing the following issue:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building standalone 1.1.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ standalone ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-property) @ standalone ---
[INFO] 
[INFO] --- liquibase-maven-plugin:2.0.1:update (empty-database-create-schema) @ standalone ---
Downloading: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/openmrs/api/openmrs-api/2.2/openmrs-api-2.2.pom
Downloading: https://repo.maven.apache.org/maven2/org/openmrs/api/openmrs-api/2.2/openmrs-api-2.2.pom
[WARNING] The POM for org.openmrs.api:openmrs-api:jar:2.2 is missing, no dependency information available
Downloading: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/openmrs/api/openmrs-api/2.2/openmrs-api-2.2.jar
Downloading: https://repo.maven.apache.org/maven2/org/openmrs/api/openmrs-api/2.2/openmrs-api-2.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.436 s
[INFO] Finished at: 2016-08-04T08:48:51-04:00
[INFO] Final Memory: 24M/970M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.1:update (empty-database-create-schema) on project standalone: Execution empty-database-create-schema of goal org.liquibase:liquibase-maven-plugin:2.0.1:update failed: Plugin org.liquibase:liquibase-maven-plugin:2.0.1 or one of its dependencies could not be resolved: Could not find artifact org.openmrs.api:openmrs-api:jar:2.2 in openmrs-repo (http://mavenrepo.openmrs.org/nexus/content/repositories/public) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

@maurya -Dopenmrs.version is platform version.

@dkayiwa, I cannot find an option mentioned in https://github.com/openmrs/openmrs-standalone except for switching a branch, can you let me know what option needs to be used so that I can update in the directions as well

I do not seem to understand the question. What do you mean by, “so that i can update in the directions as well”?

To package Reference Application from https://github.com/openmrs/openmrs-standalone, I do not find any directions to know what options to use specific to reference application. The quick summary asks us to use

mvn clean package -Dopenmrs.version=1.9.0

Similarly is there a command to be run for packaging refapp something like

mvn clean package -DrefApp.version=2.2

To phrase my question simply- “Can we build/package OpenMRS Reference Application using OpenMRS Standalone to create a standalone version (Which I strongly believe we can) ? Can you direct me to how I can do that?”

To create a standalone for the reference application version 2.4 which uses platform 1.11.6, you would use the command below:

mvn clean package -Dopenmrs.version=1.11.6 -DrefApp.version=2.4

NOTE: for the reference application standalone, you would use the openmrs-emr branch and if it is based on platform 2.0 and above, you would use the openmrs-emr2 branch

@maurya is this the answer you are looking for? :slight_smile:

Yes thank you @dkayiwa :slight_smile:

Still facing trouble building RefApp from standalone -

By running - mvn clean package -Dopenmrs.version=1.11.6 -DrefApp.version=2.4

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:copy-resources (copy-distro-modules) on project standalone: Execution copy-distro-modules of goal org.apache.maven.plugins:maven-resources-plugin:2.6:copy-resources failed. NullPointerException -> [Help 1]

After looking at our CI build plan changed the command to - mvn clean package -Dopenmrs.version=1.11.6 -Ddistro.directory=omods -Drefapp.version=2.4

–(I do not have a omods folder but believed it might be generated while building reference application)

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.1:update (demo-database-create-schema) on project standalone: Error setting up or running Liquibase: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. Can't create database 'openmrs' (errno: 2) -> [Help 1]

Just to point out, this strengthens my case on https://issues.openmrs.org/browse/STAND-85 that we need to significantly improve the docs for this.

-Darius (by phone)

Haha :slight_smile:, Actually my efforts are in respect to STAND-85.

@maurya i noticed that having been doing it all the time from bamboo at a click of a button made me forget the full command. Just tried it out locally and here is what i had to use:

mvn clean package -Dopenmrs.version=1.11.6 -DrefApp.version=2.4 -Ddistro.directory=/Projects/openmrs/distro/package/target/distro

@dkayiwa, were you able to successfully package 2.4 standalone? I still face

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.1:update (demo-database-create-schema) on project standalone: Error setting up or running Liquibase: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. Can't create database 'openmrs' (errno: 2) -> [Help 1]

I am not sure if this is something related to my environement or if there should be some setting for this to work?

@maurya whenever you get a message like “Could not create connection to database server.”, it means you have instances of mysql from the previous runs that are still hanging around. The solution is to kill them and run again.

1 Like

I didn’t think there would be more than one process. Thanks for pointing me to that.

I was able to build the standalone successfully, but I only see a 1.11.6 Standalone rather than a 2.4 Standalone, there is no trace of any modules. Also, there is only a ZIP generated through the build and has refapp.version on its name, but when it extracts, it extracts to openmrs-standalone 1.11.6.

I can confirmed that this was pointed out during the Ref App 2.4 release, but when I checked it seems the standalone had been manually renamed.

@maurya if you have no modules in the standalone’s appdata/modules folder, then clone the distro and compile it to create the modules. For instance my distro is cloned at /Projects/openmrs/distro

@dkayiwa, just to confirm, the standalone for OpenMRS Reference Application only builds the OpenMRS-core war and expects the Reference Application Modules to be built and available to be packaged as standalone. Is that correct?

@maurya it pulls the war file from the maven repository. Yes it expects the reference application modules to be built and pass the folder via the refapp argument.

@maurya and @jdegraft i have made a commit to ensure that the zip has the reference application version instead of platform version. Pull the latest changes and compile again. Also note that the modules folder argument is case sensitive. So use -Drefapp instead of DrefApp

hello @dkayiwa

i am facing a standalone build failure when buildinga ci plan for platform 2.4.x build which according to the logs seems to be due to liquibase maven plugin

@ruhanga

That CI plan is pointing to the 2.3.x branch.