面对java.lang.NoSuchMethodError:HttpServletRequest.getParts()Ljava / util / Collection [英] Facing java.lang.NoSuchMethodError: HttpServletRequest.getParts()Ljava/util/Collection

查看:1132
本文介绍了面对java.lang.NoSuchMethodError:HttpServletRequest.getParts()Ljava / util / Collection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这里看到了许多与此异常相关的问题,并且大多数问题都是通过从apache添加commons-file-upload jar来解决的。我试图使用这个解决方案,我为我的所有项目添加了相同版本的jar,但它似乎没有解决问题,我仍然面临着问题。我知道这个问题已经被问到了,但是我想知道是否有人可以帮我解决这个具体问题。这是我的堆栈跟踪:

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)

我调用时抛出异常方法 getParts 来自我的班级 RestServer 使用 HttpServletRequest ,I一直在寻找信息,它说所使用的jar的版本必须与所有项目相同,我这样做,但没有工作。

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.

调用 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.

推荐答案

javax.servlet.http.HttpServletRequest.getParts() 仅适用于Servlet API 3.0开始

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

要检查的事项:


  • Be确定你正在运行Jetty 9(或更新版本)

  • 确保你的 WEB-INF / web.xml 配置为使用Servlet API 3.0(或更新版本)

  • 确保您的构建工具使用servlet-api 3.1(或更新版)jar。

  • (可选)Make确保你的 WEB-INF / lib 目录中有相同的servlet api 3.1 jar。

  • 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.

这篇关于面对java.lang.NoSuchMethodError:HttpServletRequest.getParts()Ljava / util / Collection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆