Reputation: 663
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?
Upvotes: 0
Views: 1066
Reputation: 1754
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
Upvotes: 1