Struts 1.1 和 Servlet 2.5 - 测试期间 JspException 的 NoClassDefFoundError [英] Struts 1.1 and Servlet 2.5 - NoClassDefFoundError for JspException during tests

查看:26
本文介绍了Struts 1.1 和 Servlet 2.5 - 测试期间 JspException 的 NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将 pom 中的 servlet-api 提供的依赖项从 2.3 更新到 2.5 后,我们自定义 Struts 1.1 RequestProcessor 的单元测试开始失败,出现 NoClassDefFoundError: javax/servlet/jsp/JspException,这在 servlet-api-2.5 中确实缺乏,与 2.3 相比.

After updating servlet-api provided dependency in pom from 2.3 to 2.5, unit tests for our custom Struts 1.1 RequestProcessor started to fail with NoClassDefFoundError: javax/servlet/jsp/JspException, which indeed is lacking in servlet-api-2.5, compared to 2.3.

我使用 JUnit 4.11 和 JMockit 1.2 进行单元测试.

I use JUnit 4.11 and JMockit 1.2 for unit testing.

有趣的是,该应用程序在部署到 JBoss 5.1 后运行良好.

Interestingly, the application works fine after deploying it to JBoss 5.1.

Struts 1.1 是否与使用 servlet api 2.5 的 Web 应用程序兼容?

Is Struts 1.1 compatible with web apps using servlet api 2.5?

也许 JBoss 5.1 servlet-api 与从 maven 存储库中提取的 servlet-api-2.5 不同?

Maybe JBoss 5.1 servlet-api is different from servlet-api-2.5 taken from maven repository?

推荐答案

javax.servlet.JspException 是 JSP API 中定义的异常.JSP API 是 Servlet API 的扩展.

javax.servlet.JspException is an exception that is defined in the JSP API. The JSP API is an extension of the Servlet API.

您在 JBoss 5.1 中没有遇到此问题的原因是 JBoss 5.1 在 JBOSS_HOME\common\lib 目录中包含 jsp-api.jar.

The reason why you don't experience this issue in JBoss 5.1 is because JBoss 5.1 contains jsp-api.jar inside the JBOSS_HOME\common\lib directory.

只需在 Struts 测试项目中包含与依赖项相同的 jar.

Just include the same jar as a dependency in your Struts test project.

我希望这会有所帮助.

这篇关于Struts 1.1 和 Servlet 2.5 - 测试期间 JspException 的 NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆