3

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.

2 Answers 2

8

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.
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for the quick response, I'll check it now.
I checked all the points you mentioned, but all of them are ok, servlet-api-3.0 as well as jetty v8 are included, but not working.
Double check your build and WEB-INF/lib, you likely have more than 1 servlet api jar in your WEB-INF/lib directory (or in your build path if eclipse, or dependency tree if maven), one of which is an older incompatible version.
Look at the question and (both) answers here too: stackoverflow.com/questions/15914595/…
Thanks a bunch for the help, I've solved the issue by taking a look carefully to the issues you mentioned.
|
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.