Friday, April 1, 2011

Building and Deploying OpenMRS from the Code Base

This blog post deals with building and deploying the OpenMRS codebase. Please note that for this example I'm using SpringSource Tool Suite as my IDE.

The first step is to create a new workspace and then get the OpenMRS code. the steps for doing this are outlined at

The next thing you'll need to do is right click on the pom.xml within the openmrs project and select "Run As" --> "Maven Install"

It took about a minute for everything to build on my machine, but once it was all done I was left within a WAR file on my local hard drive. For me it was located at: C:\Users\jeremy\Documents\OpenMRS\openmrs\webapp\target\openmrs.war Please note that you'll need to "refresh" you workspace in order for it to show up in your Project Explorer tree.

The next step is to take the openmrs.war file and place it in the webapps folder within your tomcat install or for me in the customized tomcat instance provided by SpringSource. Once you either start up or restart your tomcat instance you should see a new folder in the webapps folder of your tomcat install that is called 'openmrs'.

You'll then need to go to http://localhost:8080/openmrs/index.htm

At that point you'll see a screen that asks if you want to populate the MySQL database with test data or if you want to start from scratch. Either way you'll need to provide the root password for your MySQL database so that it can be configured properly for OpenMRS.

If you choose to let OpenMRS create the test data for you then you'll next see a screen that lists 4 or 5 tasks each of which have a progress bar. I believe it took about 5 minutes for my machine to churn through everything on that page. Once that step is all done then you should see the following screen:

At that point you should be able to use the default user name / password (admin / Admin123) to check out the application. NOTE: Usually the default is admin / test, but something with this installation process changes that up.

Sunday, March 13, 2011

Getting Started With Open States -- Fun with GitHub and Public Keys

A couple months back I started to hear about a great project called Open States whose goal is to scrape data from web sites of each state within the union so that the information could be shared more easily. I really wanted to get involved with this project but there were a couple issues:
  1. Project used python (don't know it)
  2. Project hosted on GitHub (haven't used it)
  3. All of the supporting documentation was for linux users (I can use Linux as a general office worker... using it as a development platform is beyond me at the moment)
Even with all of those issues I still wanted to get involved so I read a couple books on python programming,  reviewed the code base, and tried to figure out what it meant to be a Git user along with doing development on Linux.  I started off with their Contribution Guide and read the getting Getting Started on GitHub.  Then I tried to get my environment setup.  After installing Git and the python dependencies pointed out in the Contribution Guide I tried to clone my forked version of the openstates repository and that is where the fun began.

I was supposed to be able to run the following command from the shell in order to get the code downloaded to my computer.

git clone

However, I ran into two issues.

  1. My account within Linux didn't have permission to update the known_hosts file (/home/jeremy/.ssh/known_hosts
  2. I got a permission denied message from GitHub... the exact message was "Permission denied (publickey)"

After looking at the SSH Troubleshooting guide on GitHub I realized that I skipped a couple steps in my setup.... however fixing that issue was a little harder than I would have wished. I ended up resolving the issue by running all git and ssh commands using SUDO. I know that isn't the most ideal way to do this, but I just couldn't figure out how to give my user id (jeremy) access to the /home/jeremy/.ssh/ directory. I'm sure if I would have looked into it more I would have found the solution (chmod is your friend), but I simply didn't want to deal with it at the moment. So I did the following:

  1. Executed sudo ssh-keygen -t rsa "{email address}" and at all of the prompts I just hit enter to accept defaults. This populated the /root/.ssh/ file with a key
  2. Copied key generated in file to Account Settings in GitHub. Look at step 4 on for more information
  3. Executed sudo ssh to make sure that everything was setup. If you get permission denied then that means that you didn't do something correctly :(
    1. you can use the command sudo ssh -v to get more verbose messages about the failure. If you don't see "Offering public key: /root/.ssh/id_rsa" in the debug messages then that means you don't have any public keys ready to offer.

At that point I was able to execute sudo git clone and finally the forked code was on my machine. Time for a beer.

Thursday, January 13, 2011

Glassfish Admin Console -- Problem Loading Page

Today I installed Glassfish v3 and when I tried to go to the administrative console all I went get would be a message stating that the admin console was initializing and then it would just show a gray bar at the top with a blue background.   At the same time I found the following log within my server.log file (D:\glassfish\glassfishv3\glassfish\domains\domain1\logs\server.log)

[#|2011-01-13T12:14:44.036-0600|INFO|glassfish3.0.1||_ThreadID=27;_ThreadName=Thread-1;|Cannot refresh Catalog : Connection timed out: connect|#]

It turns out that the admin console tries to call out to the internet on startup and ends up timing out when it cannot get to the internet.  For those of us who work for companies that implemented proxies this can be a bit problematic.  Luckily after doing some searching online I found some links that helped me solve the problem.  The most useful was from Stackoverflow which provided the solution (run
./asadmin create-jvm-options 

Please note that the asadmin file can be found within the bin directory of your root Glassfish installation path. 

The Stackoverflow link is:
I also was able to find a bug that discussed the problem (