Debugging OpenSRP Server on Intellij

This guide assumes you have Intellij IDEA Community and Maven installed.

Download Apache Tomcat 9 and unarchive the zip to a folder you have permissions to. Suggested location is /home/<username>/apache-tomcat-<version>

Open IntelliJ and go to FileSettings and expand Tools and select External Tools. Click + icon to add a new tool. Enter details as shown in the screenshot below:-

  • Name: Could be anything but suggested name is Tomcat

  • Program: Enter the full path to your catalina.sh

  • Arguments: jpda run

If you go to ToolsExternal Tools and click Tomcat (or the name of your tool), tomcat should start.

 

To set up Maven to build and deploy to your tomcat server, open RunEdit Configurations, click the + icon and select Maven then configure as below:-

  • Name: Could be any name e.g Deploy or the name of the project

  • Working Directory: The location of your project.

  • Commandline:-

    war:war org.codehaus.mojo:wagon-maven-plugin:upload-single -Dwagon.fromFile=/<path-to-project-dir>/target/opensrp.war -Dwagon.url=file:///home/<username>/apache-tomcat-<version>/webapps/

 

To set up debugging, click Run → Edit Configurations, click the + icon and select Remote as shown below:-

  • Name: Could be any name e.g Debug or the name of the project

  • Debugger mode: Attach to remote JVM

  • Transport: Socket

  • Host: localhost

  • Port: 8000

To debug, click on RunDebug

You are all set to debug on the OpenSRP server-side.