I'm trying to set up Eclipse to run and deploy my projects to a Jetty 7 server (the oldest version available from http://download.eclipse.org/jetty/). I've downloaded Jetty 7 and unpacked it, and I've installed the Jetty plugin from the available server adapters list, but when I try to configure a new Jetty server, the server type list only contains "Jetty 6". If I use this and point it at my server runtime, when I try to start it I get the following error:
java.lang.NoClassDefFoundError: org/mortbay/start/Main Caused by: java.lang.ClassNotFoundException: org.mortbay.start.Main at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Exception in thread "main"
I'm guessing I need a different adaptor to start Jetty 7, but I have no idea where to find it.
Running the Web ApplicationSelect the application you want to run on Jetty. Click on the Run button -> Run Configurations. Configure your app on Jetty as shown in the picture bellow and click on Run: Wait for the server to start.
The easiest way to start Jetty, is to use the start. jar that comes with the distribution. The default options may be specified in the start. ini file, or if that is not present, they are defined in the start.
BTW, as to your question in title: mvn jetty:stop fails for you (see also manual for stopPort and stopKey )? By the way. I solved my problem. after a little searching i got run-jetty-run (code.google.com/p/run-jetty-run) for eclipse.
Better than using the WTP adapters I prefer to use an embedded jetty. I just create a regular java project, let's call "embedded-jetty". I make the original webapp project a requirement to this project in the Projects section of the Java Build Path of the project properties. Than I create a class that start a jetty instance like this:
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class JettyServer {
public static void main(String[] args) {
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setResourceBase("../webapp-project/WebContent");
context.setDescriptor("../webapp-project/WebContent/WEB-INF/web.xml");
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}
}
On the embedded-jetty project I create a "lib" folder and copy all the libs from the jetty/lib folder, then I add the libs on the Libraries of the project properties.
Running and debugging the jetty embedded works great for me, the jsp and class reloading works like a charm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With