Running and Debugging DHIS2 with Tomcat on IntelliJ

I’m trying to get DHIS2 running using tomcat on intellij. I’ve done all the configuration that needs to be done but I still can’t get it to work. My main aim is to learn how to debug the application with Intellij as I’m just a beginner and I’m trying to learn my way around things here. I just want to at least get deployed with tomcat before I go into debugging it and that itself isn’t working.

Anytime I try to run tomcat, I get these logs

/usr/local/Cellar/tomcat@8/8.5.75/libexec/bin/catalina.sh run
[2022-05-18 04:11:44,087] Artifact dhis-web-portal:war exploded: Waiting for server connection to start artifact deployment...
18-May-2022 16:11:48.205 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/8.5.75
18-May-2022 16:11:48.216 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jan 17 2022 22:07:47 UTC
18-May-2022 16:11:48.216 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.75.0
18-May-2022 16:11:48.216 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Mac OS X
18-May-2022 16:11:48.217 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            12.1
18-May-2022 16:11:48.217 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86_64
18-May-2022 16:11:48.218 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home/jre
18-May-2022 16:11:48.218 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_321-b07
18-May-2022 16:11:48.218 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
18-May-2022 16:11:48.219 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /Users/nony/Library/Caches/JetBrains/IntelliJIdea2022.1/tomcat/faf81c01-782a-43b9-ba1b-b5ff9a406e02
18-May-2022 16:11:48.219 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/Cellar/tomcat@8/8.5.75/libexec
18-May-2022 16:11:48.220 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/nony/Library/Caches/JetBrains/IntelliJIdea2022.1/tomcat/faf81c01-782a-43b9-ba1b-b5ff9a406e02/conf/logging.properties
18-May-2022 16:11:48.221 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
18-May-2022 16:11:48.222 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx7500m
18-May-2022 16:11:48.222 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms4000m
18-May-2022 16:11:48.222 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
18-May-2022 16:11:48.223 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
18-May-2022 16:11:48.227 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
18-May-2022 16:11:48.227 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
18-May-2022 16:11:48.227 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/nony/Library/Caches/JetBrains/IntelliJIdea2022.1/tomcat/faf81c01-782a-43b9-ba1b-b5ff9a406e02
18-May-2022 16:11:48.227 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/Cellar/tomcat@8/8.5.75/libexec
18-May-2022 16:11:48.228 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/Cellar/tomcat@8/8.5.75/libexec/temp
18-May-2022 16:11:48.228 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/Users/nony/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
18-May-2022 16:11:49.174 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
18-May-2022 16:11:49.248 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
18-May-2022 16:11:49.299 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 3797 ms
18-May-2022 16:11:49.708 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
18-May-2022 16:11:49.709 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.75]
18-May-2022 16:11:49.726 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
18-May-2022 16:11:49.758 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 458 ms
18-May-2022 16:11:59.764 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/Cellar/tomcat@8/8.5.75/libexec/webapps/manager]
18-May-2022 16:12:01.071 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/Cellar/tomcat@8/8.5.75/libexec/webapps/manager] has finished in [1,307] ms

and that’s where it usually ends so if anyone could help me out, I’d really be grateful.
Thank you in advance.

I also just found out that when I stop tomcat from running, I get this message from IntelliJ

Application Server was not connected before run configuration stop, reason: Unable to ping server at localhost:1099

Welcome to the community @Nonso! :tada:

What guide are you following please? OpenSSL is being requested maybe because in the config you need to change, proxy_set_header to X-Forwarded-Proto http; make sure it’s not https

See this configuration and compare please:
# Proxy pass to servlet container

Hi, thank you so much for replying to me.

So there’s no particular guide that I’m using. I can’t really find anyone that instructs on how to run DHIS2 using tomcat on IntelliJ so I’m just using fore-knowledge at this point.

Also the configuration you pointed out to me isn’t the one I’m using as I’m not using nginx. Should I be using that?

1 Like

Hi @Nonso,

Is there a specific reason why you’re using IntelliJ?

If there is no specific reason then I recommend following the instructions in the documentations.

Please feel free to update this topic!

Hi @Gassim,

The reason I’m using IntelliJ is because my main aim is to learn how to debug the application so I’m just trying to get it up and running with IntelliJ first and I can’t seem to be able to do even that.

Hi @Nonso,

If the purpose is debugging using IntelliJ then I recommend you install the dhis2 instance on docker and use the Jetbrains docker integration plugin:

  1. Install dhis2 on Docker (guide: Running dhis2 locally in a container)
  2. Install the Jetbrains docker plugin (link: https://plugins.jetbrains.com/plugin/7724-docker)
  3. Follow this guide 'Docker in IntelliJ IDEA" (Docker | IntelliJ IDEA Documentation)
  4. Read more here about Docker Debug (Docker Debug | IntelliJ IDEA)

Hope this helps! :+1:

please note from jetbrain’s docs:

Thank you so much @Gassim I’ll check this out right now

1 Like

Hi once again @Gassim,

I’ve followed the steps you outlined for me so far (thank you once again for them). I was able to get a dhis2 instance up and running with docker.

I was also able to successfully install the Jetbrains docker plugin.

My problem now lies in trying to carryout the actual debugging. I followed all the guidelines in the IntelliJ documentation up until it says to
“Specify the Docker configuration you want to run”
I’m not really sure about what to specify as the Docker configuration but even if I did there’s no option for me to do as seen in the picture, it’s just an empty dropdown.

Hi @Nonso,

I’m glad you found the references helpful. Please are you using Windows or what OS are you using?

If you are using Windows, I found this instruction which might be important:

Unable to connect to Docker

Make sure that:

If you are using Docker for Windows, enable the Expose daemon on tcp://localhost:2375 without TLS option in the General section of your Docker settings.

If you are using Docker Toolbox, make sure that Docker Machine is running and its executable is specified correctly in the Settings/Preferences dialog Ctrl+Alt+S under Build, Execution, Deployment | Docker | Tools.

source: https://www.jetbrains.com/help/idea/docker.html#docker_troubleshooting

Hi @Gassim thank you so much for replying once again. Unfortunately I’m using a MacOS system :sob:

Please see here, Connect to Docker daemon with MacOS / Path mappings