I am trying to embed a Jetty server in an application and am seeing a really strange problem:
According to documentation, a simple server (which I am building as a test) can be started up using the following code:
import org.eclipse.jetty.server.Server;
public class SimpleServer throws Exception
{
public static void main(String[] args)
{
Server server = new Server(8080);
server.start();
server.join();
}
}
I believe I have the correct Jar file from the downloaded Jetty:
jetty-server-9.3.7.v20160115.jar
Unfortunately, I am seeing that the Server class I am using has no public start() method. It has a protected start() method that has a LifeCycle parameter, but that is it. The public start() method referenced in the documentation (and in several answers here in Stack Overflow) does not exist!
Am I using the right Server class? If not, where do I get a proper one???
Someone please advise...
You need also add "jetty-util-{version}" into your project and this will fix your issue. Or you can use maven in your project and add "jetty-server-{version}" as maven dependency. Maven will automatically download all jetty-server relative jars (including jetty-util-{version}).
There's no problem here.
A public modifier Server.start()
exists, and has existed since (at least) Jetty 5.0 days.
Not sure what library / build you are using, but this method is not protected, in the Server
class, the AbstractLifeCycle
(abstract) class or even the LifeCycle
interface.
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