【问题标题】:Getting Exception for Spring File upload获取 Spring 文件上传异常
【发布时间】:2011-01-13 00:34:55
【问题描述】:

我在使用 spring 文件上传功能上传文件时遇到异常。

正在尝试上传 291 KB jpg 文件。

对于小于 50 kb 的文件,它可以正常工作。以下是 bean 条目

<bean id="fileUploadController" class="com.businesscaliber.controller.FileUploadController">
        <property name="commandClass" value="com.businesscaliber.bean.FileUploadBean"/>
        <property name="formView" value="admin.do"/>
        <property name="successView" value="admin.do"/>
    </bean>

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- one of the properties available; the maximum file size in bytes -->
        <property name="maxUploadSize" value="100000"/>
    </bean> 

请帮忙

嗨,我已经更新了 spring 2.5 jar

之后出现同样的错误

11:45:29,562 INFO  [STDOUT] 147375 [http-localhost%2F127.0.0.1-9090-3] ERROR org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/businesscaliber].[businesscaliber]  - Servlet.service() for servlet businesscaliber threw exception
javax.servlet.ServletException: Circular view path [exceptionController.do]: would dispatch back to the current handler URL [/businesscaliber/exceptionController.do] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

使用 Spring 2.0 jar 的原始异常

 1782687 [http-localhost%2F127.0.0.1-9090-3] ERROR org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/businesscaliber].[businesscaliber]  - Servlet.service() for servlet businesscaliber threw exception
java.lang.StackOverflowError
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:215)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)    2010-02-04 16:43:31,406 INFO  [STDOUT] a:544)

【问题讨论】:

  • “紧急”没有任何意义;这不是支持热线。
  • 我们需要超过 2 行的堆栈跟踪来诊断堆栈溢出
  • 不幸的是,您的日志记录在堆栈跟踪变得有趣之前就截断了它。您使用的是哪个版本的 Tomcat 和 Spring?
  • 我使用的是 Jboss4.0 和 Spring-Version: 2.0.1

标签: java spring tomcat servlets


【解决方案1】:

这个StackOverflowError 显示了一个对getSession() 进行递归调用的跟踪,这是可识别的,因为请求被错误地分派到之前已经在请求链中调用过的servlet 或过滤器,导致它正在调用自身一次又一次。

实际上,我看不出这与上传文件有什么关系,也许 Spring 文件上传功能在内部将请求转发到某些特殊的 servlet 或过滤器,巧合的是,原始请求的相同 url-pattern 也涵盖了这些因此已经被预先调用。

至少,您现在知道在哪里查看以解决特定问题。 servlet 或过滤器映射中存在歧义和递归。

【讨论】:

  • 嗨,我已经用新的 2.5 jar 替换了我的旧 spring jar,得到了同样的错误,循环路径异常
猜你喜欢
  • 2014-03-10
  • 2017-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-23
  • 2018-07-31
  • 2019-07-24
  • 2012-07-31
相关资源
最近更新 更多