Menu

Help with JSP using ServletUnit

Help
Aldred
2005-04-07
2013-04-26
  • Aldred

    Aldred - 2005-04-07

    Good morning,

    I am trying to use ServletUnit to test a servlet that forwards to a JSP. Initialy I was getting ClassNotFoundExceptions, but these vanished when I added the jasper jars to my project. I was then getting 404 errors as the JSP could not be found. As a simple fix I just added my JSP to the root of my project, (I will be smarter with this a little later).

    I am now getting the following error and I am at a loss as to how to proceed. Any help in sovling this would be greatly appreciated as this is the last hurdle for my web tier TDD, (Test Driven Development) and I realy want to get it sorted out.

    The stack trace is as follows:

    com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 javax.servlet.ServletException: org/apache/tools/ant/BuildException [http://localhost/SelectBeer.do]
        at com.meterware.servletunit.ServletUnitClient.newResponse(ServletUnitClient.java:115)
        at com.meterware.httpunit.WebWindow.getResource(WebWindow.java:164)
        at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:128)
        at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:121)
        at com.meterware.httpunit.WebClient.getResponse(WebClient.java:113)
        at com.example.web.BeerSelectTest.setUp(BeerSelectTest.java:65)
        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)

    It seems that the jsp is being found ok, but quite why this error is being produced I do not know, it it possible that I am using the incorrect jars required by Jasper.

    (I am using eclipse to run junit and have the following jars in my project:

    commons-logging-api.jar
    httpunit.jar
    jasper-compiler.jar
    jasper-runtime.jar
    jsp-api.jar
    junit.jar
    nekohtml.jar
    Tidy.jar
    xercesImpl.jar
    xmlParserAPIs.jar

    Any help would be much appreciated.

    regards,

    Aldred

     
    • Lars G. Svensson

      Hi Aldred,

      I had the same problems, so I built a hacked version of httpUnit being somewhat more verbose with the exceptions, and it boiled down to two ClassNotFoundExceptions, one being BuildException (from ant) and the other one being something from commons-el. When I added ant.jar and commons-el.jar (I simply copied from the tomcat distribution) to the classpath it worked for me.

      Lars

       

Log in to post a comment.

MongoDB Logo MongoDB