SDK: Help with setting up server using installed MySQL

Tags: #<Tag:0x00007f828ee6d080> #<Tag:0x00007f828ee6cf68> #<Tag:0x00007f828ee6cdb0>

@bci, I am splitting this topic and bringing on the current post my answer regarding your issue(s) specifically with the SDK when setting up the Ref App distro, quote:

Reference: In the wiki article ‘OpenMRS SDK’, look at ‘Setup OpenMRS Platform 1.11.7-SNAPSHOT on MySQL database’ in the examples subsection. There is an example there showing what is expected for the -DdbUri parameter.

See a step by step guide below the line.


Find below more detailed instructions about how to setup Ref App 2.5. I’m a assuming that

  • You are on a Un*x-like OS.
  • MySQL 5.6 is installed and running on port 3306.
  • Java 8 is installed, that’s mandatory for Platform 2.0.

Fetch the latest SDK and setup the server:

mvn openmrs-sdk:help -U # make sure you run the latest SDK release
mvn openmrs-sdk:setup -DserverId=distro-2-5 -Ddistro=referenceapplication:2.5-SNAPSHOT -DdbUri=jdbc:mysql://localhost:3306/openmrs_distro-2-5 -DdbUser=root -DdbPassword=pass

Where root is MySQL’s root user and pass is the root user’s password. Eventually you will be asked:

Which database would you like to use?:

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

Pick 1).

Then you will be asked something along those lines:

Which JDK would you like to use to run this server?:

  1. JAVA_HOME (currently: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre)
  2. /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/
  3. Other…

Make sure you provide the path to Java 8’s JRE. In the above example you would have to pick 2) and then the build would complete. You may have to paste the path by yourself though if it is not provided as above.

Now to run this server on port 8080:

mvn openmrs-sdk:run -Dport=8080 -DserverId=distro-2-5

Watch the log in your terminal and launch the webapp (http://localhost:8080/openmrs/) when you see this: INFO: Starting ProtocolHandler ["http-bio-8080"]. You will then see this:

Let this complete to 100%. Actually you can even close the browser’s window and get back to the terminal and observe that it keeps running until the log calms down and that nothing happens anymore (this will take a few minutes). At that point you can access the Ref App 2.5 at the same URL as earlier.

Hi @mksd Dimitri, Thank you very much, sorry for not being clear, and please tell me if my thougths are entirely wrong …

ref app 2.5 is not stable, that is beta. So we aim for ref app 2.4.

a/ the set up - we can do it now (no sdk, the prod), of the platform (1.11.6), but, we cannot add all modules of 2.4 - crash

b/ for sdk: such, we are aiming, also, to develop for 2.4. “db access” - sorry, of course that work. what I mean, is, there is not an option (like there is for the maven archetype) to create service & dao classes (not sure if that is used for 2.4 also, but the mvn produces such … please see here: https://wiki.openmrs.org/display/docs/Using+the+Module+Maven+Archetype c) Creation of Demo Module with a service/dao layers: - the SDK does not provide this question

idea was, to develop with the SDK. but for 2.4, for the prod use of 2.4. … the SDK seems not to provide the creation of the service/dao - say - we did not find it may I ask, is it provided, or not anyhow?

other question: the ref app 2.4. since not even these (modules) seem to run, on Java 7 (which maybe more people have good experience with) - we scare to use 2.5, of Java 8, which is more new also the location, we want to find local supporters … … maybe rather possible with Java 7…

… I would be glad about your opinion, please share, thank you! :slight_smile: … hehe on a Sunday …

@bci if you run any version of openmrs (e.g reference application 2.4) and get failures of modules or anything else, providing the jetty or tomcat log is the first step in getting help. :slight_smile:

Hi @bci,

Regarding your point a/, would you mind starting a new post and provide all the necessary details as to what exactly is being done? And as Daniel said, please provide all relevant logs. Not only I think it will deserve its own thread but as you can imagine “crash” is too vague for anyone else to know what’s going on.

I’m sorry but I fail to understand what you exactly mean then regarding your points b/ and c/, or even how those two questions/remarks differ from each other. Anyway I was just re-running the Maven archetype to build a new module:

mvn module-wizard:generate

And one of the questions is:

Do you want to add a service layer: (y/n) y: :

Did you answer y? In which case the wizard will generate the boilerplate code and configuration for creating a service and implementing the DAO layer. Assuming that the default ‘Basic Example’ name is kept, all these files are generated:

  • BasicExampleService.java
  • BasicExampleDAO.java
  • BasicExample.hbm.xml
  • HibernateBasicExampleDAO.java
  • BasicExampleServiceImpl.java

Also moduleApplicationContext.xml and config.xml are prepared to work fine with the above.

As I have no idea what your requirements are I don’t know if the above is really necessary. I would assume that it is quite unlikely that you even need to go down that path to be honest. A combination of the Core/Platform, the REST Web Services module and the EMR API module will probably cover almost 100% of any use case.

Hi @mksd, Thank you very much for your detailed answer (sorry for answering now, I was away from the web :slight_smile:

1/ yes, thank you, I also think that core, rest, emr, will cover our reqs. I will try to install them (maybe compile them, if there is a dependency issue - that probably was the case with what i did before). I will try 2.5., see if it runs

2/ sorry, maybe I do not understand (however, I do not mind what to use) - the mvn archetype feature (yes, I can create dao/service, of course) and the SDK, in the page of e.g. “SDK 3.0 released” … or so, don’t remember clearly (something like: openmrs-sdk:create-project …)

  • they are 2 methods? As it is: using the SDK (starting with setting up a server. Then, create-project … ) there is no question to create a dao/service layer. - Sorry, I do not understand if both are related, or if i rather might use maven archetype or maven SDK … or both

Thank you and have a good day

Hi @bci,

First of all you don’t have to first setup & start a server before creating a project. The documentation invites you to create a project at that point because they assume that the reason why you setup & started a server in the first place was to develop an OpenMRS module.

Anyway you are correct that there are two ways (basically an older one and a newer one) to generate a module. I would assume that this is the newer one:

mvn openmrs-sdk:create-project

And you are right that it doesn’t ask whether the developer wants to add a service layer or not, it just does it, which is harmless btw.

@raff, could you shed some light here, should mvn module-wizard:generate be deprecated, although it is more interactive than the newer mvn openmrs-sdk:create-project?

Hi @mksd, Thank you very much for the explanation, i see. Also thank you for mentioning that the dao/service layer is created by the SDK, just tried it, it is. Sorry that I haven’t seen it before. Have a good day