随笔-46  评论-64  文章-2  trackbacks-0
这个问题是在使用Struts2想做一个上传文件的页面时候Tomcat报出来的错误,详细信息如下:
2007-7-19 21:34:09 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.RuntimeException: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location]
    at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:136)
    at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:476)
    at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:486)
    at com.opensymphony.xwork2.inject.ContainerImpl$9.call(ContainerImpl.java:517)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:542)
    at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:515)
    at org.apache.struts2.dispatcher.Dispatcher.wrapRequest(Dispatcher.java:697)
    at org.apache.struts2.dispatcher.FilterDispatcher.prepareDispatcherAndWrapRequest(FilterDispatcher.java:330)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:595)
Caused by: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location]
    at org.apache.struts2.config.BeanSelectionProvider$ObjectFactoryDelegateFactory.create(BeanSelectionProvider.java:246)
    at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:134)
    ... 22 more

最后Google了不少文章,找到了原因:(缺少了必要的jar包)

Struts2使用开源项目Apache Jakarta Commons FileUpload和内建的FileUploadInterceptor拦截器实现文件上传,所需的jar包如下:

commons-logging-1.1.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.6.jar
xwork-2.0.1.jar
commons-io-1.3.1.jar
commons-fileupload-1.2.jar


参考资料:

在Struts 2中实现文件上传

Struts2文件上传



posted on 2007-07-19 21:57 jht 阅读(17140) 评论(11)  编辑  收藏 所属分类: Struts2

评论:
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location][未登录] 2008-05-24 00:15 | super
感谢 good,我就遇到了同样的问题  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2008-08-25 10:18 | 与世有争
谢谢兄台  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2008-08-25 15:19 | cvc
fgfg  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2008-09-15 16:54 | qin
我也出现了这样的问题,不过我那jar包添加进去了的
不过改web.xml,把原来的
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
改为
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
就行了  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2008-09-29 23:04 | hai
非常感谢、。。  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2009-02-20 16:59 | 璩立健
我加了包,怎么报NULLPOINTexception,UploadFileAction 的属性没自动赋值  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location][未登录] 2010-10-20 15:48 | qq
所有的包加了还是不行  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location][未登录] 2010-10-24 17:16 | allen
thanks  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2011-08-14 21:45 | amenmen
多谢了!  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2011-09-08 08:39 | tbw
我就遇到了同样的问题  回复  更多评论
  
# re: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location] 2011-12-10 21:14 | wuyhbzh01@163.com
哈哈哈··可以了·。。谢谢!!不知道为什么会这样,这样改了就成功提交了。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: