I get an exception when using MockStrutsTestCase.
With the servlet-api.jar from Tomcat 4.1.18 it runs fine.
The program is taken from the book "Jakarta Struts Live" by Rick Hightower.
I work under Eclipse 3 and the paths are set correctly (I even included 'WEB-INF/lib' to the classpath, but this is not needed at least with the Tomcat 4.1.18 'servlet-api.jar').
Below is the code extract from "UserRegistrationActionTest.java", where the exception triggers and also the exceptions:
Exceptions:
12:42:59,328 ERROR [MessageResourcesFactory] MessageResourcesFactory.createFactory
java.lang.NoClassDefFoundError: javax/servlet/jsp/JspException
at org.apache.struts.util.MessageResourcesFactory.createFactory(MessageResourcesFactory.java:192)
at org.apache.struts.util.MessageResources.getMessageResources(MessageResources.java:576)
at org.apache.struts.action.ActionServlet.initInternal(ActionServlet.java:1329)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:326)
at strutsTutorial.UserRegistrationActionTest.setUp(UserRegistrationActionTest.java:31)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
12:42:59,359 ERROR [MockStrutsTestCase] Error initializing action servlet
java.lang.NullPointerException
at org.apache.struts.util.MessageResources.getMessageResources(MessageResources.java:577)
at org.apache.struts.action.ActionServlet.initInternal(ActionServlet.java:1329)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:326)
at strutsTutorial.UserRegistrationActionTest.setUp(UserRegistrationActionTest.java:31)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Any help is appreciated, thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I get an exception when using MockStrutsTestCase.
With the servlet-api.jar from Tomcat 4.1.18 it runs fine.
The program is taken from the book "Jakarta Struts Live" by Rick Hightower.
I work under Eclipse 3 and the paths are set correctly (I even included 'WEB-INF/lib' to the classpath, but this is not needed at least with the Tomcat 4.1.18 'servlet-api.jar').
Below is the code extract from "UserRegistrationActionTest.java", where the exception triggers and also the exceptions:
"public void setUp() throws Exception {
super.setUp();
ServletContext context = null;
context = getActionServlet().getServletContext();"
^ line 31 ^
Exceptions:
12:42:59,328 ERROR [MessageResourcesFactory] MessageResourcesFactory.createFactory
java.lang.NoClassDefFoundError: javax/servlet/jsp/JspException
at org.apache.struts.util.MessageResourcesFactory.createFactory(MessageResourcesFactory.java:192)
at org.apache.struts.util.MessageResources.getMessageResources(MessageResources.java:576)
at org.apache.struts.action.ActionServlet.initInternal(ActionServlet.java:1329)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:326)
at strutsTutorial.UserRegistrationActionTest.setUp(UserRegistrationActionTest.java:31)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
12:42:59,359 ERROR [MockStrutsTestCase] Error initializing action servlet
java.lang.NullPointerException
at org.apache.struts.util.MessageResources.getMessageResources(MessageResources.java:577)
at org.apache.struts.action.ActionServlet.initInternal(ActionServlet.java:1329)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:464)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:326)
at strutsTutorial.UserRegistrationActionTest.setUp(UserRegistrationActionTest.java:31)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Any help is appreciated, thanks in advance.
PS: I use Struts 1.1 and
StrutsTest 212-1.1_2.3