0

I am assigned a project in which we attempt to push content from a Jetty server to one or more connected clients, using the SPDY protocol. Changes to the current pushing strategy and handlers are required, so I want to change the server's implementation and be able to debug the newly inserted code. I downloaded Jetty's source code from GitHub, and can use the mvn clean install command to generate a distribution in jetty-distribution/target/distribution.

To write my own server handlers en strategies, I loaded all Maven projects in NetBeans, and everything can be build from the top project down. I defined my own handlers, and by passing the right arguments in the project Jetty-Start (jetty home and base) and using the right XML configurations, I can start the server in debug mode from within Java. I can the debug the main class, but in the main, Jetty is executed in another JVM:

// execute Jetty in another JVM
if (args.isExec())
{
    CommandLineBuilder cmd = args.getMainArgs(baseHome,true);
    cmd.debug();
    ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs());
    StartLog.endStartLog();
    final Process process = pbuilder.start();
    Runtime.getRuntime().addShutdownHook(new Thread()
    {
        @Override
        public void run()
        {
            StartLog.debug("Destroying " + process);
            process.destroy();
        }
    });

    copyInThread(process.getErrorStream(),System.err);
    copyInThread(process.getInputStream(),System.out);
    copyInThread(System.in,process.getOutputStream());
    process.waitFor();
    System.exit(0); // exit JVM when child process ends.
    return;
}

When accessing the server through the browser, no breakpoint in the server's code is ever triggered. I really need to be able to understand the flow from the request handlers to the pushing strategy, so how can I fully debug the server's implementation?

jvdhooft
  • 657
  • 1
  • 12
  • 33

1 Answers1

1

You can add some parameters into your JVM :Run jetty with this

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000

than run remote and debug with this

-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000

Hope it will helps

Milkmaid
  • 1,659
  • 4
  • 26
  • 39
  • Thank you for your reply. I looked into remote debugging, and I can start the server from command window using the following command: `java -Xdebug -Xrunjdwp:transport=dt_socket,address=8585,server=y,suspend=n -jar start.jar --module=spdy`. Inside NetBeans, I can add a debugger, listening at host localhost and port 8585 and NetBeans indeed goes in debug mode. However, still no breakpoint is triggered. Is there anything specific that needs to be handled here? – jvdhooft Dec 05 '14 at 08:51
  • You change adress port from 4000 to 8585 but its not port of jetty. Its port of debug listener you should use 4000 or smth Imho. – Milkmaid Dec 05 '14 at 08:55
  • I managed to make it work, by using your suggestion and using a similar approach to http://stackoverflow.com/questions/9205063/processbuilder-debugging. Thanks a lot! – jvdhooft Dec 05 '14 at 12:25