root1982
root1982

Reputation: 470

ServletRequest NoSuchMethodError

My env Jetty 8.1

public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
  //this line prints org.eclipse.jetty.server.Request
  System.out.println("class is "+request.getClass().getName());

  org.eclipse.jetty.server.Request jettyRequest = (org.eclipse.jetty.server.Request)request;
  //request.getServletContext();//this line fails with noSuchMethodError
  jettyRequest.getServletContext(); // this line works

  ...

Can anyone explain this....?

Upvotes: 0

Views: 108

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49515

Your webapp isn't using Servlet API 3.0.

This will fail if you are using Servlet API 2.5 (for example).

Make sure your webapp's WEB-INF/web.xml is set for Servlet API 3.0 and also make sure that any servlet-api jars you might have in WEB-INF/lib are removed.

Upvotes: 2

Related Questions