Search code examples
gradlebuild.gradlegretty

Debugging gradle web application in Jetty


I am new to Gradle. I am using Buildship in eclipse. My build.gradle looks like,

gretty {
    httpPort = 8080
    contextPath = '/'
    servletContainer = 'jetty9'
}

When I debug the application as, 'gretty -> appStartDebug', the console waits saying like,

Listening for transport dt_socket at address: 5005

My project is a web application with init as,

@WebServlet(urlPatterns="/InitServlet", loadOnStartup=0)
public class InitServlet extends HttpServlet {
}

public static void initialize() {
 system.out.println("Initializing");
}

I have my break point in the sysout. Is this proper way of debugging gradle application?


Solution

  • The console is waiting for your debugger process to attach to the socket.

    1. Create a new remote debugging session in Eclipse
    2. Execute gradle task appStartDebug and wait for message:

      Listening for transport dt_socket at address: 5005

    3. Run your previously configured remote debug configuration in Eclipse

    4. Stop debugging your web application with gradle task appStop

    Read for more information and also on how to debug in IntelliJ IDEA here.