Search code examples
debuggingweb-applicationsintellij-ideajettymaven-jetty-plugin

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


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.


Solution

  • 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