问题
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