Openmrs-SDK failed to setup server

Can you please help, I’ve been stuck for ages and would love to get on with OpenMRS? Up to now I’ve had success following the instructions given on OpenMRS SDK documentation (https://wiki.openmrs.org/display/docs/OpenMRS+SDK#OpenMRSSDK-Installation). I have the following installed:

  • MySQL Server version: 5.6.35 MySQL Community Server (GPL).

  • Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T02:11:47+09:30) Maven home: /Applications/apache-maven-3.3.9 Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: “mac os x”, version: “10.10.5”, arch: “x86_64”, family: “mac”

  • java version “1.8.0_121” Java™ SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot™ 64-Bit Server VM (build 25.121-b13, mixed mode)

I’ve read through everything I can find about the topic including a post on TALK “While installing Openmrs SDK i got an error after running mvn clean install openmrs-sdk:run”. I’ve tried all suggestions but I still get an error setting up a server as follows.

MikeGordon:/ default$ mvn openmrs-sdk:setup -e [INFO] Error stacktraces are turned on. [INFO] Scanning for projects… [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] — openmrs-sdk-maven-plugin:3.8.2:setup (default-cli) @ standalone-pom —

Setting up a new server…

Specify server id (-DserverId) (default: ‘server’): 1

You can setup the following servers:

  1. Distribution
  2. Platform

Which one do you choose? [1/2]: 2

You can deploy the following versions of a platform:

  1. 2.1.0-SNAPSHOT
  2. 2.0.4.1
  3. 2.0.4
  4. 1.12.0
  5. 1.11.7
  6. 1.10.4
  7. Other…

Which one do you choose? [1/2/3/4/5/6/7]: 1 [INFO] Configured Artifact: org.openmrs.distro:platform:2.1.0-SNAPSHOT:jar [INFO] Copying platform-2.1.0-SNAPSHOT.jar to /Users/default/openmrs/1/openmrs-distro.jar [INFO] Configured Artifact: org.openmrs.web:openmrs-webapp:2.1.0-SNAPSHOT:war [INFO] Copying openmrs-webapp-2.1.0-SNAPSHOT.war to /Users/default/openmrs/1/openmrs-2.1.0-SNAPSHOT.war [INFO] Configured Artifact: org.openmrs.module:fhir-omod:1.7.0-SNAPSHOT:jar [INFO] Configured Artifact: org.openmrs.module:webservices.rest-omod:2.17:jar [INFO] Configured Artifact: org.openmrs.module:owa-omod:1.6.3:jar [INFO] Copying fhir-omod-1.7.0-SNAPSHOT.jar to /Users/default/openmrs/1/modules/fhir-1.7.0-SNAPSHOT.omod [INFO] Copying webservices.rest-omod-2.17.jar to /Users/default/openmrs/1/modules/webservices.rest-2.17.omod [INFO] Copying owa-omod-1.6.3.jar to /Users/default/openmrs/1/modules/owa-1.6.3.omod

If you want to enable remote debugging by default when running the server, specify the port number here (e.g. 1044). Leave blank to disable debugging. (Do not do this on a production server) (default: ‘no debugging’): 1044

Which database would you like to use?:

  1. H2
  2. MySQL 5.6 (requires pre-installed MySQL 5.6)
  3. MySQL 5.6 in SDK docker container (requires pre-installed Docker)
  4. Existing docker container (requires pre-installed Docker)

Which one do you choose? [1/2/3/4]: 2

The distribution requires MySQL database. Please specify database uri (-DdbUri) (default: ‘jdbc:mysql://localhost:3306/@DBNAME@’):

Please specify database username (-DdbUser) (default: ‘root’): root Please specify database password (-DdbPassword) (default: ’ '): [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:11 min [INFO] Finished at: 2017-04-03T21:49:18+09:30 [INFO] Final Memory: 18M/99M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:3.8.2:setup (default-cli) on project standalone-pom: Failed to setup server: Failed to connect to the specified database jdbc:mysql://localhost:3306/1?autoReconnect=true&sessionVariables=storage_engine%3DInnoDB&useUnicode=true&characterEncoding=UTF-8 -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:3.8.2:setup (default-cli) on project standalone-pom: Failed to setup server at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to setup server at org.openmrs.maven.plugins.Setup.setup(Setup.java:266) at org.openmrs.maven.plugins.Setup.executeTask(Setup.java:605) at org.openmrs.maven.plugins.AbstractTask.execute(AbstractTask.java:181) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) … 20 more Caused by: java.lang.IllegalStateException: Failed to connect to the specified database jdbc:mysql://localhost:3306/1?autoReconnect=true&sessionVariables=storage_engine%3DInnoDB&useUnicode=true&characterEncoding=UTF-8 at org.openmrs.maven.plugins.Setup.setup(Setup.java:206) … 24 more [ERROR] [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/MojoExecutionException

1 Like

Try specifying your server id as “one” instead of “1”. “1” does not seem to be a valid db name and server id is used to construct a db name. Let me know, if it worked so we can add validation.

1 Like

Thanks for your reply @raff. I tried: Setting up a new server…

Specify server id (-DserverId) (default: ‘server’): one

You can setup the following servers:

  1. Distribution
  2. Platform

Which one do you choose? [1/2]: 2 but I get the same error. Do you have any other suggestions?

1 Like

Could having the following set up interfere with the server connection? Maven home: /Applications/apache-maven-3.3.9 Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre

Can you login to your mysql instance using the mysql command line client?

@mikejg I can create a database the name one, usually a problem occurs when using the username root with a blank password - I would recommend changing the root user to have an actual password

@raff yes I can @ssmusoke I wish I could too but still the same with giving root a password, the same as my MySQL password.

@mikejg Check if the database already exists … If it does then SDK will fail as it tries to create a new database for each server …

sorry @ssmusoke, check if which database already exists?

@mikejg The database with the same name as your server - one in this case…

Otherwise try using a different server name eg devtest1 (something unique)

@ssmusoke I tried a unique server name, and still no cigars

Could you please connect with the mysql command line client and share what the “status” command prints for you?

mysql Ver 14.14 Distrib 5.6.35, for macos10.12 (x86_64) using EditLine wrapper

Connection id: 6 Current database: Current user: default@localhost SSL: Not in use Current pager: stdout Using outfile: ‘’ Using delimiter: ; Server version: 5.6.35 MySQL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql.sock Uptime: 4 hours 56 min 54 sec

Threads: 6 Questions: 116 Slow queries: 0 Opens: 69 Flush tables: 1 Open tables: 62 Queries per second avg: 0.006

Looks good. How about the following query?

SHOW VARIABLES WHERE Variable_name = ‘port’;

mysql> SHOW VARIABLES WHERE Variable_name = ‘port’; ±--------------±------+ | Variable_name | Value | ±--------------±------+ | port | 3306 | ±--------------±------+ 1 row in set (0.01 sec)

Good as well. How about

mvn openmrs-sdk:help

?

/ default$ mvn openmrs-sdk:help [INFO] Scanning for projects… Downloading: https://dl.bintray.com/openmrs/maven/org/openmrs/maven/plugins/maven-metadata.xml Downloading: https://dl.bintray.com/openmrs/maven/org/apache/maven/plugins/maven-metadata.xml Downloading: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/openmrs/maven/plugins/maven-metadata.xml Downloading: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/apache/maven/plugins/maven-metadata.xml Downloading: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/codehaus/mojo/maven-metadata.xml Downloaded: https://dl.bintray.com/openmrs/maven/org/openmrs/maven/plugins/maven-metadata.xml (432 B at 0.2 KB/sec) Downloading: https://dl.bintray.com/openmrs/maven/org/codehaus/mojo/maven-metadata.xml Downloaded: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/openmrs/maven/plugins/maven-metadata.xml (723 B at 0.2 KB/sec) Downloading: https://dl.bintray.com/openmrs/maven/org/openmrs/maven/plugins/openmrs-sdk-maven-plugin/maven-metadata.xml Downloading: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/openmrs/maven/plugins/openmrs-sdk-maven-plugin/maven-metadata.xml Downloaded: http://mavenrepo.openmrs.org/nexus/content/repositories/public/org/openmrs/maven/plugins/openmrs-sdk-maven-plugin/maven-metadata.xml (368 B at 0.3 KB/sec) Downloaded: https://dl.bintray.com/openmrs/maven/org/openmrs/maven/plugins/openmrs-sdk-maven-plugin/maven-metadata.xml (2 KB at 0.7 KB/sec) [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] — openmrs-sdk-maven-plugin:3.8.2:help (default-cli) @ standalone-pom —

OpenMRS SDK 3.8.2

For more info, see SDK documentation: https://wiki.openmrs.org/display/docs/OpenMRS+SDK

usage: create-module Description: Create OpenMRS Reference Application module.

usage: create-platform-module Description: Create OpenMRS Platform module.

usage: setup Description: Setup a new instance of OpenMRS server. It can be used for setting up a platform or a distribution. It prompts for any missing, but required parameters. -DaddDemoData Add demo data when setting up a platform server. -DdbDriver Database driver e.g. ‘mysql’ or ‘h2’. -DdbPassword Password for the database user. -DdbUri Uri for JDBC connection to the database (default value matches dbDriver) -DdbUser Username for the database (defaults to ‘root’). -Ddistro OpenMRS Distribution to setup in a format ‘groupId:artifactId:version’. You can skip groupId, if it is ‘org.openmrs.distro’. -Dfile Path to installation.properties file for batch setup. -Dplatform OpenMRS Platform version to setup e.g. ‘1.11.5’. -DserverId Unique id of a server.

usage: deploy Description: Deploy a module/distribution/platform to a server. It can be used for deploying a new artifact or upgrading/downgrading an artifact, which was previosly deployed. -DartifactId Artifact id of an artifact, which you want to deploy. -DgroupId Group id of an artifact, which you want to deploy (defaults to ‘org.openmrs.module’). -DserverId Unique id of a server. -Dversion Version of an artifact, which you want to deploy.

usage: undeploy Description: Undeploy a module from a server. -DartifactId Artifact id of a module, which you want to undeploy. -DgroupId Group id of a module, which you want to undeploy (defaults to ‘org.openmrs.module’). -DserverId Unique id of a server.

usage: reset Description: Reset server and its database to the initial state. -Dfull If ‘true’, delete modules installed manually (defaults to ‘false’). -Dserverid Unique id of a server.

usage: delete Description: Delete a server and its database. -DserverId Unique id of a server.

usage: run Description: Start a server. If it is run from a module/distro/platform project, the project will be redeployed before launching. -Ddebug Enable remote debugging on the given port (defaults to ‘1044’ if empty). -Dfork Set to ‘false’ to disable forking a process for running the server (defaults to ‘true’). Useful for debugging within an IDE without a remote debugger. Not that ‘false’ disables the live-reloading feature. -Dport Port to use for running the server (defaults to ‘8080’). -DserverId Unique id of a server.

usage: watch Description: Add a module from the current directory to the list of watched projects. It enables the live-reloading feature for a module. -DserverId Unique id of a server.

usage: unwatch Description: Remove a module from the list of watched projects. It disabled the live-reloading feature for a module. -DartifactId Artifact id of a module to unwatch. -DgroupId Group id of a module to unwatch. It is optional, if artifact id is unambiguous. -DserverId Unique id of a server.

usage: info Description: Display server details including the list of watched modules. -DserverId Unique id of a server.

[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 14.426 s [INFO] Finished at: 2017-04-04T00:11:06+09:30 [INFO] Final Memory: 16M/56M [INFO] -

I’m running out of ideas…

Can you try creating the database yourself? Run in the mysql client:

CREATE DATABASE one;

Next use “one” as the server id…

I get this far

"mysql> CREATE DATABASE one; Query OK, 1 row affected (0.02 sec)

mysql> " but I’m not sure how to input the server id?

Just use “one” as the server id when executing openmrs-sdk:setup.