Reputation: 7021
I want to integrate jetty as module to be used as server for my application.
I m using maven to load dependencies for jetty as follow :
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
And I'm following this tutorial to buil my server https://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty#Configuring_Connectors
here is the code I want to run :
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.AbstractConnector;
public class FileServer {
public static void main(String[] args) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase(".");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, new DefaultHandler()});
server.setHandler(handlers);
server.start();
server.join();
}
}
However i've got errors in this part :
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
it cannot detect SelectChannelConnector neither setPort() !
Any help ? thanks
Upvotes: 0
Views: 1710
Reputation: 49525
The giant red box at the start of that wiki page tells you ...
Jetty 7 and Jetty 8 are now EOL (End of Life)
All development and stable releases are being performed with Jetty 9.
This wiki is now officially out of date and all content has been moved to the Jetty Documentation Hub
Direct Link to updated documentation: http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
In short, you can't use Jetty 8 code and mechanisms on Jetty 9.
Follow the link to the Jetty 9 documentation to see the up to date documentation and code examples
Upvotes: 1