Setting up Jetty in Eclipse [duplicate]
Asked Answered
M

4

5

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

Mother answered 15/11, 2010 at 1:58 Comment(0)
F
5

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).

Friarbird answered 15/11, 2010 at 10:17 Comment(3)
I'm fairly sure that the additional Jetty adapter that cerealk refers to doesn't support Jetty 7... I could be wrong, but I think that I've run into that.Cauley
The only adapter I see is for Jetty 6. By Mortbay Software.Erdman
This no longer seems to work in Eclipse Neon.Partan
R
4

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();
}
Reinsure answered 15/11, 2010 at 1:58 Comment(1)
Can you please explain how to integrate this in Eclipse?Erdman
T
3

As a developer of Run-Jetty-Run , I strongly suggest to use Run-Jetty-Run plugin , if you meet any question ,please feel free to post issues .

http://code.google.com/p/run-jetty-run/issues/list

I will try to take a look as possible as I could.

Transcendental answered 19/12, 2011 at 22:58 Comment(0)
T
1

Or you can use Maven! add the Jetty plugin in the pom.xml!

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.9</version>
  <configuration>
    <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
      <append>true</append>
    </requestLog>
  </configuration>
</plugin>

And in the Run Configurations Window, add an entry to Maven Build ! You just have - to choose a name for your new command - to choose your project - in the goals, write -Djetty.port=8900 jetty:run

So, when you run with this command, your application will be available at this address : http://localhost:8900

Tamratamsky answered 10/1, 2011 at 12:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.