Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up Jetty in Eclipse [duplicate]

I'm trying to follow a tutorial on Tapestry. (http://tapestry.apache.org/tapestry5.1/tutorial1/env.html) The tutorial recommends Jetty 5.1 so I can use a plugin called JettyLauncher to run Jetty applications from inside Eclipse. Right now though, Jetty is at version 7 I believe. I don't want to start with an out of date web server. Does Jetty 7 have any eclipse plugins similar to what I imagine Jetty 5.1 + Jetty Launcher is supposed to do?

Thanks

EDIT: I'm trying Run Jetty Run and m2eclipse. We'll see how this works

like image 675
JPC Avatar asked Nov 15 '10 01:11

JPC


2 Answers

you can go to window -> preferences -> server -> runtime environments and choose to add a new server environment. in th efollowing dialog you can download the "additional server adapters". ther you can chose the Jetti adapter. This way you can configure and use jetty as stated in the WTP documentation (i.e you can configure a new jetty instance in the server view and start stop synch it from there).

like image 92
pbanfi Avatar answered Nov 02 '22 21:11

pbanfi


Running Jetty through the m2eclipse (jetty:run) works very well. On the other hand, my preferred way of using Jetty is starting in embedded mode (i.e. launching it programatically). This snippet works for Jetty 6, including debugging. I haven't tested it in Jetty 7, but I guess it can be easily adapted for 7:

Server server = new Server(8080);

WebAppContext webapp = new WebAppContext();
webapp.setParentLoaderPriority(true);
webapp.setContextPath("/");
webapp.setWar("src/main/webapp");
server.setHandler(webapp);
try {
    server.start();
    server.join();
}
catch (Exception e) {
    e.printStackTrace();
}
like image 22
Thiago H. de Paula Figueiredo Avatar answered Nov 02 '22 20:11

Thiago H. de Paula Figueiredo