在运行struts junit时获取java.lang.NoClassDefFoundError:javax / el / ELResolver

问题描述 投票:1回答:1

我正在为struts动作类编写junits并使用org.apache.struts2.StrutsTestCase,在运行测试用例时我得到的是异常。

 java.lang.NoClassDefFoundError: javax/el/ELResolver
at org.apache.struts2.tiles.StrutsTilesInitializer.createContainerFactory(StrutsTilesInitializer.java:58)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:123)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
at com.dmainc.agora.action.test.SetupStrutsTestCase.setUp(SetupStrutsTestCase.java:261)

所以我在运行配置中添加了el-api.jar,然后再次运行测试,但开始得到另一个例外,即

java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
at org.apache.tiles.el.JspExpressionFactoryFactory.getExpressionFactory(JspExpressionFactoryFactory.java:61)
at org.apache.struts2.tiles.StrutsTilesContainerFactory.createELEvaluator(StrutsTilesContainerFactory.java:251)
at org.apache.struts2.tiles.StrutsTilesContainerFactory.createAttributeEvaluatorFactory(StrutsTilesContainerFactory.java:198)
at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:106)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)

我猜这是因为某些jar / jar版本有冲突,但无法弄清楚为什么?任何建议将受到高度赞赏。

struts2
1个回答
0
投票

解决方案1:apache-tomcat-x.x.xx \ lib文件夹内部的el-api.jar文件集classpath环境变量。

解决方案2:将apache-tomcat-x.x.xx \ lib \ el-api.jar文件复制到jreX.X.X_XXX \ lib \ ext \文件夹中。

因为它用于预加载tomcat服务器启动

再次运行您的测试用例。

© www.soinside.com 2019 - 2024. All rights reserved.