Debug web app in IntelliJ, webapp built by maven, run by jetty

33,084

Solution 1

The easiest way is to:

  1. Expand your project in the Maven Projects tab.
  2. Expand Plugins > jetty items.
  3. Right-click jetty:run.
  4. Choose Debug from the context menu.

screen shot of "Maven Projects" panel, context-menu to run Jetty in debug mode

Solution 2

I know it's too late to reply this question, but It's worth sharing the latest update on this issue as a modern solution: You can also run jetty using “mvnDebug jetty:run” which has the same effect. Which display the following logs in the terminal

Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8000
[INFO] Scanning for projects...

Just remember to choose the correct socket address(e.g. 8000), then:

  1. Open Intellij
  2. Run -> Edit Configuration
  3. In Run/Debug Configuration window, you need to click on (+) button to add a new configuration
  4. Select Remote
  5. Keep the default configuration as is, just change the listening port to corresponding one (8000).

Enjoy.

Solution 3

When I was getting "main config file not included" it was because the path to Jetty in my Application Server configuration (on Run/Debug Configurations dialog) was deleted during my OS X upgrade (I had put it in /usr/share/java).

I reinstalled jetty-hightide-8.1.5.v20120716 under /usr/local, updated the configuration and all is well.

Share:
33,084
EyeQ Tech
Author by

EyeQ Tech

Founder at [EyeQ Tech][1] [1]: https://eyeq.tech/review-cong-ty-eyeq-techs-company-trip?utm_source=stackoverflow&utm_medium=stackoverflow&utm_term=stackoverflow&utm_content=TungAccount&utm_campaign=stackoverflow

Updated on August 13, 2020

Comments

  • EyeQ Tech
    EyeQ Tech almost 4 years

    I'm using s/o code, it's a java webapp built by maven. The webapp is run by maven script, like below, and the app is run on localhost:8080, :

    <build>
            <plugins>
                <plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>8.1.8.v20121106</version>
                    <configuration>
                        <contextPath>/</contextPath>
                        <connectors>
                            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                                <!--<port>8085</port>-->
                                <port>8080</port>
                                <maxIdleTime>60000</maxIdleTime>
                            </connector>
                        </connectors>
                        <stopKey>stop</stopKey>
                        <stopPort>8089</stopPort>
                    </configuration>
                </plugin>            
            </plugins>
    </build>
    

    I want to attach the debugger of IntelliJ so that I can step through the code. I tried to set up a debugger configuration like: Jetty Server, then 'Remote' but it said Application Server not specified. I also tried with 'Local', it said 'main config file not included'.

    So what must I do to attach the debugger? Thanks in advance.

  • t-my
    t-my over 9 years
    How do you make this a run configuration?
  • Andras Deak -- Слава Україні
    Andras Deak -- Слава Україні almost 8 years
    It's never too late to reply to a question (well, to an on-topic question), as long as the answer is good.
  • manasouza
    manasouza almost 7 years
    Definitely this should be the best answer
  • sergpank
    sergpank over 6 years
    This is definitely the best answer for the case when the one needs remote debugging!
  • Ahmad AlMughrabi
    Ahmad AlMughrabi about 6 years
    @sergpank, I'm happy to see this answer is helpful. Thank you :)
  • Basil Bourque
    Basil Bourque almost 6 years
    I can vouch for this approach with IntelliJ 2018.2 on macOS.