Struts 1.1 and Servlet 2.5 - NoClassDefFoundError for JspException during tests

落爺英雄遲暮 提交于 2019-12-24 13:44:08

问题


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.

I use JUnit 4.11 and JMockit 1.2 for unit testing.

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

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

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


回答1:


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

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.

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

I hope this helps.




回答2:


you need to add jsp-api to you dependencies http://search.maven.org/#search|ga|1|a%3A%22jsp-api%22



来源:https://stackoverflow.com/questions/18207959/struts-1-1-and-servlet-2-5-noclassdeffounderror-for-jspexception-during-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!