0
votes

My embedded Jetty has the following file at /home/user/Desktop/jetty-web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com
/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"/>

I start my server with the following code:

    Server server = new Server();

 SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(ServerConfig.PORT);
        connector.setMaxIdleTime(ServerConfig.MAX_IDLE_TIME);
        connector.setRequestHeaderSize(ServerConfig.REQUEST_HEADER_SIZE);
        server.setConnectors(new Connector[]{connector});

WebAppContext webAppContext = new WebAppContext();
webAppContext.setDescriptor("/home/user/Desktop/jetty-web.xml");
webAppContext.setBaseResource(Resource.newResource("/"));
        webAppContext.setContextPath("/");

//add a few servlets...

server.setHandler(webAppContext);

server.start();

My intention is to run with the Servlet API 3.0. When I compile just the Jetty part of my project this works fine. However, when I add an external library that uses an older version of Jetty(Hadoop core) my embedded Jetty server downgrades to 2.5 and throws a NoSuchMethodError on a HttpRequest#getParts call. How can I force my Jetty server to run with Java Servlets 3.0?

I'm using Jetty 8.1.16.v20140903.

1

1 Answers

1
votes

If using a build tool, exclude jetty and the servlet-api pieces from the hadoop dependencies.

Simply be sure you don't use old versions of Jetty.