bengreen.eu Circle Device

 

Quick Reference

Jetty in Eclipse and Spring

Install Jetty WTP in Eclipse and Spring Source

http://download.eclipse.org/jetty/updates/jetty-wtp/development/

This is fine for an embedded jetty instance on all Jetty versions but if you want to use v9.2+ and need JSP support this will NOT work. Plese see my other notes for more details and a solution.

WTP Replacement for Jetty in Eclipse

I found that installing the WTP was not working for me all the time and just wanted to use Jetty with the basic IDE (rather than the full fat Java EE IDE). For this I came up with a simple short programme that I put in my src/test/java/ directory (forgot to mention I use Maven but this will work without).

package cmdline.test;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

public class ServerRun {
	public static void main(String[] args) throws Exception {
		Server server = new Server(8080);
		
		WebAppContext webAppContext = new WebAppContext();
		webAppContext.setDescriptor("src/main/webapp/WEB-INF/web.xml");
		webAppContext.setResourceBase("src/main/webapp/");
		webAppContext.setContextPath("/core");
		webAppContext.setParentLoaderPriority(true);
		
		server.setHandler(webAppContext);
		
		server.start();
		server.join();
	}
}

/core is the URL you will need to use to get to your servlets. If you are not using the Maven project structure you will also need to make changes to the other directories. When run in Debug mode this has the usual advantages of Eclipse Java development the kind-of hot code replace stuff.

Quick Links: Techie Stuff | General | Personal | Quick Reference