How to debug openmrs-core

Hello everyone,

I have setup openmrs manually and i’m doing some changes and development in openmrs-core and attachment module.

So my question is how to debug openmrs running with mvn jetty:run with any IDE (Eclipse or IntelliJ) ?

Can anyone suggest me the steps to debug openmrs ?

Thanks in advance.

@pratikbiz24 Start the OpenMRS in debug mode and for Intellij follow this link.

I saw this post previously and have configured the IntelliJ like this:-

but i don’t know how to start openmrs in debug mode.

Like in normal mode I start openmrs by this command “mvn jetty:run” but exactly I don’t know how to start it in debug mode.

mvnDebug jetty:run is usually what I use. Note that you need to connect to the remote JVM via the JVM debug port, not the web port (8080). If you use mvnDebug command, this will be port 8000.


Thanks @ibacher :innocent:, I was looking for this solution from a long time. It’s working.

also can you please tell me how to debug any module, let say “attachment module”.

It’s basically the same process. You’d just be connecting to it from an IDE project with the module in question open. If you want to debug a module deployed to an SDK instance, you need to use a command like mvnDebug openmrs-sdk:run -DserverId=<server> -Dfork=false. If you want to debug a module in Jetty, you need to deploy it to the modules subfolder of the main OpenMRS folder (creating it if necessary). On Windows, this should be %APPDATA%\OpenMRS.

1 Like

So you mean that i have to add breakpoints in the attachment module’s source code where i want to debug, then need to make omod from attachment module’s source code and then need to deploy it on the modules folder ?

Currently I’m adding breakpoints in attachment module’s source code then making omod from that and deploying it to modules folder and running openmrs-core with mvnDebug jetty:run

but I’m not able to debug the module. So am i doing right or i need to follow some other steps ?

Well, break-points don’t exist in code. They are entirely a fiction of your IDE, and that’s the important part.

What you need to do is deploy the OMOD to the modules file, as you are doing, run mvnDebug jetty:run, but then ensure that your IDE has the attachments module project open and that it’s from that window that you connect the debugger to the OpenMRS instance.

To be a bit more concrete about this, I primarily use IntelliJ, so, unfortunately, I’m not as knowledgable about Eclipse, but one of the things I work on is the FHIR module and have a test instance that I use to debug. I actually have several different projects that are all setup to point to this one instance. So, when I have the FHIR2 module open, my IDE uses this configuration:

But I’ve also need to step through code in core, so my copy of openmrs-core also has this configuration:

(You can see I’ve actually connected from my OpenMRS core project to several SDK instances). The important detail is that your IDE has the source code for the module you want to debug open in it… otherwise, it’s very hard to properly set breakpoints (which, again, only exist for your IDE). Hope that helps!


Thanks @ibacher for the detailed explanation. I followed the steps as you mentioned and it’s working :sweat_smile: