struts2 异常Unable to load bean 文件struts-default.xml
来源:互联网 发布:linux cent 7 怎么登入 编辑:程序博客网 时间:2024/05/20 16:39
摘要: 项目中需要升级struts到struts2.5.14.1,这个版本有较大的改动,于是出现了较多的jar包冲突。很郁闷的是,很多问题在jetty服务器下,才会发生。
日志的处理
struts2.5.14.1的日志使用了log4j2的配置,如果项目中没有用到log4j,可能需要在引入struts的pom配置中exclude相关的日志处理包。并且在项目的合适位置引入log4j2.xml
的配置文件。
关于jar包xwork-core
struts的低版本中用到了xwork-core,但是目前该包的最高版本是2.3.34,已经不能和struts版本保持一致,是因为struts放弃了对xwork-core的维护,而将struts中需要的xwork-core的内容全部移入到了struts-core中。所以,请不要在高版本的struts项目中引入以下依赖:
<dependency> <groupId>org.apache.struts.xwork</groupId> <artifactId>xwork-core</artifactId> <version>2.x.y</version></dependency>
freemarker.jar的冲突
新版的struts中用到了新版本的freemarker可能会导致冲突,需要exclude
asm.jar的冲突
新版的struts中用到了新版本的asm可能会导致冲突,需要exclude
Unable to load bean
这个异常有好多个变种,它们的原因基本都是jar包冲突。
Unable to load configuration. - bean - xxx/struts2-core-2.x.y.jar!/struts-default.xml:29:72
这个异常特别常见,出现这个异常,首先应该去确认项目中是否引入了两个版本不同的struts2-core-xxx.jar
定位struts-default.xml文件到第29行,总之是错误发生的那一行。比如可能是下面这行:
<bean type="org.apache.struts2.components.template.TemplateEngine" name="jsp"
class="org.apache.struts2.components.template.JspTemplateEngine" />- 结合错误中的
Caused by:
后面的内容,找到问题的发生原因,下面这个是ClassNotFoundException
,说明肯定缺少jar包Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.JspWriter
- 手动导入相关的jar包,比如在pom.xml中加入下面依赖:
<dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.1</version> <scope>provided</scope></dependency>
Unable to load bean: type:com.opensymphony.xwork2.XXX /struts2-core-2.0.11.2.jar!/struts-default.xml:135:154
- 首先应该去确认项目中是否引入了两个版本不同的struts2-core-xxx.jar
- 还好定位struts-default.xml文件到错误发生的那一行第135行
- 结合错误中的
Caused by:
后面的内容Caused by : java.lang.IncompatibleClassChangeError: Implementing class
- 这就是说,有一个jar包的版本太低,不能满足struts的基本需求,需要升级相应jar包到最新版。
Unable to load bean:type:com.opensymphony.xwork2.TextProviderFactory
如果有上面这个问题,直接移除xwork-core的依赖就可以了。
Caused by: Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory with the name spring has already been loaded by bean
如果有上面这个问题,一般是因为在struts整合spring的时候,struts的版本与struts2-spring-plugin-xxx.jar的版本不对应。
- struts2 异常Unable to load bean 文件struts-default.xml
- Struts2.x异常 Unable to load configuration. - action ..........struts.xml或者struts-default
- struts2 -- Unable to load configuration - bean - jar:file: struts-default.xml:47:178(已解决)
- struts2出现Unable to load configuration. - bean - jar:file:/...struts-default.xml问题
- struts2 :Unable to load configuration. ……struts-default.xml:46:178异常解决
- struts2 :Unable to load configuration. ……struts-default.xml:46:178异常解决
- JAR包不全!Unable to load configuration.-bean-jar:file:/.../struts2-core-2.2.1.jar!/struts-default.xml:7
- Struts2 Unable to load configuration. - bean - jar ..... WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178 解决办法
- Struts2 Unable to load configuration. - bean - jar ..... WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178 解决办法
- Struts2 Unable to load configuration. - bean - jar ..... WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178 解决办法
- Unable to load configuration .../WEB-INF/struts2-core-2.3.20.jar!/struts-default.xml:82:179
- 启动JBoss出现“Unable to load configuration struts-default.xml”异常解决
- Unable to load configuration--struts-default.xml:40:72
- 解决struts报错问题Unable to load configuration struts2-core-2.3.16.3.jar!/struts-default.xml:40:72
- struts2:Unable to load configuration.......WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48
- 解决Struts2报错!!Unable to load configuration struts2-core-2.2.3.jar!/struts-default.xml:29:72报错
- [Struts2异常]关于发生Struts配置异常:Unable to find parent packages struts-default.xml的解决方案
- Struts2学习之Unable to load configuration. - bean 异常
- 12年经验老程序员的5次转型
- Java中的异常有哪几类?分别怎么使用
- git 理解 HEAD指针&branch指针
- argc、argv 介绍及使用
- Day10 --包 匿名内部类
- struts2 异常Unable to load bean 文件struts-default.xml
- 幂等和高并发在电商系统中的使用
- CNM哦
- Unity中的角色属性芒星比例图
- 从图库中选取图片设置给ImageView
- markdown编辑器
- Windows平台下,编译Curl+OpenSSL
- 初识java这个小姑娘(三)
- 一个新的起点~规划