Menu

NullPointerException with .js and base tag

2003-01-18
2003-01-20
  • Frape Lohse

    Frape Lohse - 2003-01-18

    I fetched a NullPointerException with this call stack:
    java.lang.NullPointerException
        at com.meterware.httpunit.HTMLPage.getIncludedScript(HTMLPage.java:108)
        at com.meterware.httpunit.HTMLPage$1.getIncludedScript(HTMLPage.java:275)
        at com.meterware.httpunit.parsing.DOMParser.getIncludedScript(NekoHTMLParser.java:154)
        at com.meterware.httpunit.parsing.ScriptFilter.startElement(ScriptFilter.java:86)
        at org.cyberneko.html.HTMLTagBalancer.startElement(Unknown Source)
        at org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(Unknown Source)
        at org.cyberneko.html.HTMLScanner$ContentScanner.scan(Unknown Source)
        at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
        at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
        at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
        at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:221)
        at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:50)
        at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:273)
        at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:983)
        at com.meterware.httpunit.WebResponse.getForms(WebResponse.java:304)

    I tried 1.5, 1.5.1 and the latest version from CVS. They behave all the same way. The problem is that WebRequest.getWindow() returns a null pointer.

    Here is the header of my HTML page:

    <!--DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" -->
    <html lang="en">
       <head>
        <title>MessagePlus/Open</title>
        <base href="http://localhost:8080/mpo-webclient/mpo-default-page.jsp">
       
       <link href="/mpo-webclient/mpo.css;jsessionid=j16aaz8yh1" rel="stylesheet" type="text/css">
       <script language="JavaScript" src="/mpo-webclient/mpo.js;jsessionid=j16aaz8yh1" type="text/javascript"></script>
      </head>

    Can anyone help?

    TIA, Frape

     
    • Russell Gold

      Russell Gold - 2003-01-19

      Can you make a sample that I can run to duplicate the problem?

       
      • Frape Lohse

        Frape Lohse - 2003-01-20

        Well, it must be something trivial that I make wrong. Here is the code:

                WebRequest req = new GetMethodWebRequest( "http://www.mydom.com/tt/tt.html" );
                WebConversation wc = new WebConversation();
                WebResponse res = wc.getResource( req );
                System.out.println(res.getText()); /* just to verify the HTML */
                WebForm[] forms = res.getForms(); /* BINGO */

        and the HTML that I put onto an internal web server:

        <html>
            <head>
                <script src="/tt/tt.js" type="text/javascript" ></script>
            </head>
            <body>just a test</body>
        </html>

        The tt.js file is just empty. And here is again the exception:

        java.lang.NullPointerException
            at com.meterware.httpunit.HTMLPage.getIncludedScript(HTMLPage.java:108)
            at com.meterware.httpunit.HTMLPage$1.getIncludedScript(HTMLPage.java:275)
            at com.meterware.httpunit.parsing.DOMParser.getIncludedScript(NekoHTMLParser.java:154)
            at com.meterware.httpunit.parsing.ScriptFilter.startElement(ScriptFilter.java:86)
            at org.cyberneko.html.HTMLTagBalancer.startElement(Unknown Source)
            at org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(Unknown Source)
            at org.cyberneko.html.HTMLScanner$ContentScanner.scan(Unknown Source)
            at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
            at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
            at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
            at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:221)
            at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:50)
            at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:273)
            at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:983)
            at com.meterware.httpunit.WebResponse.getForms(WebResponse.java:304)
            at mytest.test.LoginTest.testLogin(LoginTest.java:32)

        Removing the src attribute makes the exception disappear.

        Regards, Frape

         

Log in to post a comment.

Auth0 Logo