Issue Details (XML | Word | Printable)

Key: CACTUS-22
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vincent Massol
Reporter: Josie Gioffre
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cactus

ServletTestCase crashes with 'Not a valid response'

Created: 31/May/02 10:49 PM   Updated: 17/Apr/04 04:14 PM
Return to search
Component/s: Framework
Affects Version/s: 1.3
Fix Version/s: 1.4-beta1

Time Tracking:
Not Specified

Environment:
Operating System: Windows NT/2K
Platform: PC

Bugzilla Id: 9544


 Description  « Hide
Platform details:
Weblogic 6.1 sp2, on Windows 2000 (5.00.2195)
Java: Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
      Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

Problems details:
I was running my cactus test cases when I experienced the errors shown below.
I was able to reproduce it consistently. It seems to be that whenever the
servlet is initialised and doPost() is called, any action taken afterwards will
result in this error. An example is providing a endXXX(WebResponse wr) method,
and calling wr.getText() within the method. This was one case that triggered
the error.

The problems also seems to occur when re-deploying the application in WebLogic
and not restarting the server.

My code for the test case is as follows:

public class FormConfigurationActionTest extends ServletTestCase {

    ActionServlet _servlet = null;


    public FormConfigurationActionTest(String testName) {
        super(testName);
    }

    public void setUp(){
    }

    public void tearDown() {
        _servlet = null;
    }


    public void beginCreateQuestionFromMenu_Update(WebRequest wRequest) {
        String pathInfo = null;
        String queryString = null;

        // Request variables expected
        wRequest.addParameter("formPrimaryContext",
FormsConfigHelper.CONTEXT_CREATE_EDIT_QUESTION);
        wRequest.addParameter("updateFlag", FormsConfigHelper.ACTION_UPDATE);
        wRequest.addParameter("questionLanguageId", "1");
        wRequest.addParameter("questionType", Question.BOOLEAN_QUESTION);
        wRequest.addParameter("questionDescription", "Is this working
properly?");

        // <form> Action
        wRequest.setURL
("localhost:7001", "/ermtest", "/forms/createeditquestion.do", pathInfo,
queryString);
    }

    public void testCreateQuestionFromMenu_Update() {
        try {
            _servlet = new ActionServlet();
            _servlet.init(config);
            _servlet.doPost(request,response);
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        catch (ServletException e) {
            e.printStackTrace();
        }

// ** AN ACTION HERE CAUSES THE ERROR
     }



    public static Test suite() {
        TestSuite suite = new TestSuite();
        suite.addTest(new FormConfigurationActionTest
("testCreateQuestionFromMenu_Update"));
        return suite;
    }
}




*************************************

Client-side stack trace:

    [junit] Running com.jobpartners.testsuite.FormConfigurationActionTest
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 1.072 sec
    [junit] Testsuite: com.jobpartners.testsuite.FormConfigurationActionTest
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 1.072 sec
    [junit]
    [junit] Testcase: testCreateQuestionFromMenu_Update took 1.062 sec
    [junit] Caused an ERROR
    [junit] Not a valid response
    [junit] org.apache.cactus.util.ChainedRuntimeException: Not a valid response

    [junit] at org.apache.cactus.client.WebTestResultParser.readRootElement(
WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):134)
    [junit] at org.apache.cactus.client.WebTestResultParser.dispatch29_parse
(WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):101)
    [junit] at org.apache.cactus.client.WebTestResultParser.around29_parse(W
ebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):1221)
    [junit] at org.apache.cactus.client.WebTestResultParser.parse(WebTestRes
ultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):96)
    [junit] at org.apache.cactus.client.AbstractHttpClient.callGetResult(Abs
tractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):231)
    [junit] at org.apache.cactus.client.AbstractHttpClient.dispatch1_doTest(
AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):123)
    [junit] at org.apache.cactus.client.AbstractHttpClient.around1_doTest(Ab
stractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):1221)
    [junit] at org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHt
tpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):115)
    [junit] at org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTes
tCase.java:457)
    [junit] at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.jav
a:133)
    [junit] at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.j
ava:400)
    [junit]
    [junit] Testcase: testCreateQuestionFromMenu_Update

BUILD FAILED

****************************************

Server-side stack trace

<31-May-02 16:31:47 BST> <Error> <HTTP> <[WebAppServletContext(5690625,ermtest,/
ermtest)] Servlet failed with Exception
java.lang.NullPointerException
        at org.apache.cactus.server.AbstractTestCaller.doGetResults(AbstractTest
Caller.java:195)
        at org.apache.cactus.server.AbstractTestController.dispatch79_handleRequ
est(AbstractTestController.java;org/apache/cactus/util/log/LogAspect.java(1k):12
9)
        at org.apache.cactus.server.AbstractTestController.around79_handleReques
t(AbstractTestController.java;org/apache/cactus/util/log/LogAspect.java(1k):1147
)
        at org.apache.cactus.server.AbstractTestController.handleRequest(Abstrac
tTestController.java;org/apache/cactus/util/log/LogAspect.java(1k):101)
        at org.apache.cactus.server.ServletTestRedirector.dispatch88_doPost(Serv
letTestRedirector.java;org/apache/cactus/util/log/LogAspect.java(1k):132)
        at org.apache.cactus.server.ServletTestRedirector.around88_doPost(Servle
tTestRedirector.java;org/apache/cactus/util/log/LogAspect.java(1k):1147)
        at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedi
rector.java;org/apache/cactus/util/log/LogAspect.java(1k):118)
        at org.apache.cactus.server.ServletTestRedirector.dispatch87_doGet(Servl
etTestRedirector.java;org/apache/cactus/util/log/LogAspect.java(1k):105)
        at org.apache.cactus.server.ServletTestRedirector.around87_doGet(Servlet
TestRedirector.java;org/apache/cactus/util/log/LogAspect.java(1k):1147)
        at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedir
ector.java;org/apache/cactus/util/log/LogAspect.java(1k):101)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
        at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2495)
        at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2204)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vincent Massol added a comment - 01/Jun/02 03:24 PM
Hi Josie,

Thanks for your bug report. I think you're making several points here. The
first one is your problem with putting an action after your doPost(). This is
forbidden by the Servlet API because the doPost() will have already returned
the response (buffers will have been flushed and connection closed). You can
write some code there but it must only be "read-only" code like checking
what's in the session, etc. Well anything that doesn't have to do with the
response. For checking the response, this should be done in endXX().

Now WRT weblogic redeployment, I think it has to do with Ant. There were some
threads on that subject not long ago on the Cactus list (check the archive).
In order to know what's happening, you should turn Cactus logging on and the
log will show exactly the reason for the "not a valid response".

Agreed, we should improve the exception handling for this but it is not that
easy. I have found yet a good solution on how to do this.

Tell me if this makes sense.

Thanks
-Vincent

Daniel Dennison added a comment - 13/Jun/02 12:52 AM
I am encountering the same bug (same exact stack trace) with a somewhat
different setup. I am using Java 1.3, Weblogic 6.1, Window NT 4.0. I am using
a JspTestCase. I did turn on debugging and found the following part quite
interesting:

12:39:13,792 [main] DEBUG util.IoUtil - <getText =
[<webresult></webresult>
]
12:39:13,792 [main] DEBUG client.WebTestResultParser - >parse
([<webresult></webresult>
])
12:39:13,802 [main] DEBUG tag.TestExampleTag - Exception in test
12:39:13,802 [main] DEBUG util.ChainedRuntimeException - >printStackTrace
([org.apache.log4j.spi.VectorWriter@499159])
12:39:13,802 [main] DEBUG util.ChainedRuntimeException - <printStackTrace
org.apache.cactus.util.ChainedRuntimeException: Not a valid response
at org.apache.cactus.client.WebTestResultParser.readRootElement
(WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):134)

Looking at the code for WebTestResultParser, you can see that it is checking
that the response ends with "</webresult>". For whatever reason, there is a
newline appended on the end of the result causing the exception to be thrown.
One way to make a nice report on the exception is to go ahead and include the
text of the response that caused this to happen.

Vincent Massol added a comment - 15/Jun/02 06:05 PM
Hi Daniel,

I have fixed the bug you mention with the end of line character in CVS.
However, I don't think Josie's problem was the same, which is why I am closing
this bug and will reopen it if Josie thinks it is still a bug.

Thanks for your contribution.

-Vincent