Question

I've seen many issues related to this exception here in so and most of them are being solved by adding a "commons-file-upload" jar from apache. I tried to use this solution and I've added the same version of the jar for all my projects, but it does not seem to fix the problem, I'm still facing the problem. I know this question has been already asked, but I wonder if somebody could give me a hand with this specific problem. This is my stacktrace:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getParts()Ljava/util/Collection;
    at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer.getParameters(RESTServer.java:378)
    at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer.parseURLRequest(RESTServer.java:367)
    at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer.access$0(RESTServer.java:354)
    at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer$1.handle(RESTServer.java:67)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
    at org.eclipse.jetty.server.Server.handle(Server.java:346)
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
    at java.lang.Thread.run(Thread.java:662)

The exception is thrown when I invoke the method getParts from my class RestServer using HttpServletRequest, I've been looking for information and it says that the version of the jar used must be the same for all the projects and I did it that way, but not working.

The piece of code invoking the getParts() :

private Map<String,Object> getParameters(HttpServletRequest request,boolean jsonp, String callback) {
        Map<String,Object> lsParameteres = new HashMap<String, Object>();       
            Collection<Part> parts = null;
            try {
                parts = request.getParts();//The exception begins here!

I will be grateful if somebody could help me, thanks for your time. Best regards.

Was it helpful?

Solution

javax.servlet.http.HttpServletRequest.getParts() is only available starting with Servlet API 3.0

Things to check:

  • Be sure you are running Jetty 9 (or newer)
  • Make sure you have your WEB-INF/web.xml configured to use Servlet API 3.0 (or newer)
  • Make sure your build tool is using the servlet-api 3.1 (or newer) jars.
  • (Optionally) Make sure you have the same servlet api 3.1 jar in your WEB-INF/lib directory.

OTHER TIPS

I encountered the same issue. It happened when I switched to Tomcat 6. When I switched back to Tomcat 7, the issue disappeared.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top