---
title: "Struts2常见异常总结"
author: "孤独剑"
date: "2009-06-01T00:39:00Z"
tags: ["Apache", "Bean", "Dojo", "Spring", "Struts"]
slug: "struts2"
draft: false
lastmod: "2009-06-01T00:39:00Z"
id: 399326
url: "https://anqli.iteye.com/blog/399326"
---

最近一直在学习Struts2的相关内容，现将在学习过程中遇到的各种异常及解决方法整理如下，希望能对初学者有所帮助

 

1：java.lang.NoClassDefFoundError: org/apache/struts2/dojo/views/jsp/ui/HeadTag

 解决方法：原因缺少了dojo的JAR包，引入即可:struts2-dojo-plugin-2.1.2.jar

 

2：Unable to load configuration. - bean - jar:file:/F:/Struts2/Struts2/WebRoot/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178  
 Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest -  

bean - jar:file:/F:/Struts2/Struts2/WebRoot/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178  
  Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext

解决方法：缺少JAR包，引入commons-fileupload-1.2.1.jar，commons-io-1.3.2.jar即可

3：在Tomcat启动时,产生如下异常:  
 严重: Exception starting filter struts2 Cannot locate the chosen ObjectFactory implementation: spring

struts.properties 文件设置如下:  
struts.objectFactory = spring  
原因:  缺少 struts2-spring-plugin-2.0.11.1.jar 包  
Struts2 中使用 Spring 的 IOC 应加入以下 jar 包  
 spring-core-2.0.5.jar

 spring-beans-2.0.5.jar

 spring-context-2.0.5.jar

 spring-web-2.0.5.jar

struts2-spring-plugin-2.0.11.1.jar