configuring OpenMRS + Tomcat + IDEA

Has anyone ever setup OpenMRS to run in tomcat via InteliJ Idea just by clicking the run button? I’m working with openmrs 1.9.11. For some reason Jetty doesn’t work on that branch so I’m forced to use Tomcat. But with tomcat to test every change I have to build, redeploy and restart the tomcat server. I don’t want to do that. I found tutorials on the internet that showed me how to add a run configuration in IDEA that makes use of tomcat.

I’ve added a Tomcat run configuration but when I run the project everything seems to work fine from IDEA but when I try to access OpenMRS in the browser every request is redirected to initialSetup without host and port number in the link.

Why don’t u use OpenMRS SDK? Then you can setup the mvn openmrs-sdk:run -DserverId=aserver as an external command.

If you are doing UI changes or working with HTML Forms u do not even have to restart the server


Didn’t know you could use the sdk when developing core. Always thought was just for modules.

1 Like

Still not sure how you use the sdk to develop core.

But I figured out how to do what I want. Only I didn’t use IDEA. Eclipse works great. I setup tomcat within eclipse and configured liver reload and start the project in debug mode and not only do I no longer need to worry about uploading and restarting tomcat, eclipse also provides hotswap. So after every change all I need to do is refresh my browser.

Welcome back to Eclipse! :smile:

1 Like

At the end of the day opensource truimphs :joy::joy::joy::joy:

Moving back to eclipse too after my intelliJ license expired, kind of missed eclipse all this time :wink:!

1 Like

Hi @ivange94, could you teach me how to do this. I want when am developing a module to just refresh a page and all my changes are deployed right from the API, leave alone what the uiframework hot deployment avails :slight_smile:

@samuel34 if your module is a RefApp module that is uses the UI Framework then you can use the sdk for that. But if you’re developing a module for legacyui then @ssmusoke or @bholagabbar may be able to help you here. They’ve done that before. Here I needed live reload for openmrs-core itself. I can look up how you can do this in a legacyui module but the above mentioned people have already done it before. @ssmusoke even wrote a blog about it. Maybe he can share it with you. :slight_smile:

Yap @ivange94 it is but using this only renders changes in the controller, gsp and static resource files. I wanna live reload changes even at the module API level. @ssmusoke any advice

You will need to restart the server for Java API changes, no way around that

For the Java changes, can you try spring-loaded?

The question is how do we use this tool with the openmrs-sdk any resources around @dkayiwa?

Is this of help?

I’d just like to point out that the correct answer to this is to not do it at all! :slight_smile:

If you are writing back-end code, you should be doing test-driven development 100% of the time. There’s truly no excuse not to do this, and:

  • You will write better code, by taking a moment to think about how you’ll use the code before diving straight into writing it.
  • You will automatically have high test coverage for your code
  • You will save time

Trust me on this. Years ago I was not a believer, but the first time I really tried TDD I realized that it saves time even in the short term. And our tooling has gotten better since then. It’s really worth trying the TDD approach instead!


Thanks for the advice @darius, gonna depend on that.