title: HtmlUnit in Java returning errors when browsers work fine
body: <p>I'm trying to log into a site using HTMLUnit, but whenever I submit my logon details I get a massive chain of errors. I broke my code up into little pieces so I can see that it's after the submit button is clicked, but before anything else happens; it takes a while because it's a pretty slow site. Because it happens after a login I can't show you what it's meant to look like, unfortunately. I can say that a successful login has a few redirects, and because it's giving me a page not found error I'm assuming that it's one of those redirects that's causing the trouble. I have had redirect trouble with Chrome here before, although not on this particular page, and both Chrome and IE8 are loading it fine for me now.</p>
  
  <p>Saving you the full stack trace, here's what appears to be the most important stuff:</p>
  
  <pre><code>SEVERE: Error loading JavaScript from [http://servicedeskmt.det.nsw.edu.au:8090/kinetic/displayPage.jsp/../resources/js/jquery/jquery-1.3.2.js].
  com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 /kinetic/resources/js/jquery/jquery-1.3.2.js for http://servicedeskmt.det.nsw.edu.au:8090/kinetic/resources/js/jquery/jquery-1.3.2.js
  at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:535)
  INFO: statusCode=[404] contentType=[text/html]
  Oct 31, 2011 2:31:29 PM com.gargoylesoftware.htmlunit.WebClient printContentIfNecessary
  INFO: &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Page cannot be found&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
  
  
  &lt;/head&gt;
  
  &lt;body bgcolor="#FFFFFF" text="#000000"&gt;
  &lt;div align="center"&gt;
    &lt;p&gt;&amp;nbsp;&lt;/p&gt;
    &lt;p&gt;&amp;nbsp;&lt;/p&gt;
    &lt;p&gt;&lt;b&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;There was 
      an error on the page you were attempting to reach or the page could not be 
      found.&lt;/font&gt;&lt;/b&gt; &lt;br&gt;
    &lt;/p&gt;
    &lt;p&gt;&lt;br&gt;
      &lt;br&gt;
      &lt;a href="http://www.kineticdata.com"&gt;&lt;img src="resources/poweredByKS.gif" width="131" height="45" border="0"&gt;&lt;/a&gt; 
    &lt;/p&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any advice would be greatly appreciated.
  Thanks.</p>
  
  <p>EDIT: Adding some more detail
  The error occurs on loginButton.click(), whether I set the result to equal a new page or not. A line that is just loginButton.click() causes a long pause (like I say, the page takes a while to load), then throws the error. If I catch the exception and then try to load the logged-in version of the page the same thing happens, which tells me that my login attempt is successful, but loading the logged in page is causing a problem.
  Storing the credentials in the DefaultCredentialsProvider, then going straight to the logged in page, gives the same error. I think I can safely say it's the page, not the login.</p>
  
  <p>Loading the page, and in the same statement running javascript or clicking on a button, has the same effect. I was hoping that some other part of the page wasn't loading properly but I could still fire off the bit that I wanted, but no luck.</p>