views:

327

answers:

1

Hi all,

I am having intermittent issues saving the response HTML in HtmlUnit.

Caused by: java.io.IOException: Unable to save file:C:\ccview\PP50773_4.0_walter\TSC_hca\Applications\HCA_J2EE\HCA\target\HtmlUnitTests\single\1\com\pnc\tsc\hca\ui\test\SiteCrawler\crawlSiteAsProvider\10.SiteCrawler.crawl.html
    at com.pnc.tsc.hca.ui.util.GetUtil.save(GetUtil.java:128)
    at com.pnc.tsc.hca.ui.util.GetUtil.add(GetUtil.java:75)
    at com.pnc.tsc.hca.ui.util.GetUtil.click(GetUtil.java:49)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:87)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:61)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:54)
    at com.pnc.tsc.hca.ui.test.SiteCrawler.crawlSiteAsProvider(SiteCrawler.java:50)
    ... 15 more
Caused by: java.lang.RuntimeException: java.io.IOException: The system cannot find the path specified
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.getAttributesFor(XmlSerializer.java:165)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.printOpeningTag(XmlSerializer.java:126)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:83)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:93)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:93)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.asXml(XmlSerializer.java:73)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.save(XmlSerializer.java:55)
    at com.gargoylesoftware.htmlunit.html.HtmlPage.save(HtmlPage.java:2259)
    at com.pnc.tsc.hca.ui.util.GetUtil.save(GetUtil.java:126)
    ... 24 more
Caused by: java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:883)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.createFile(XmlSerializer.java:216)
    at com.gargoylesoftware.htmlunit.html.XmlSerializer.getAttributesFor(XmlSerializer.java:160)
    ... 32 more

Now, the parent directory exists and some other files have already been written to the directory. Looking at the filename, I don't see anything that would stand out as a red flag indicating the filename is bad.

What can I do to correct this error?

Thanks,

Walter

A: 

Well, you are well within the maximum path length. The exception trace clearly believes it is a path problem. I would try some additional tests to help isolate the problem. Check the directory before writing with: File.exists(), File.isDirectory(), File.isWritable(). Similar checks on the file itself. May want to see if the disk is full too.

If you can get a little more information on the source of the problem, we can get it resolved.

Thanks,

Brett

The thing is, this fails randomly. I have a crawler which crawls the entire web application so perhaps the first 9 pages work fine, and then page 10 dies for some odd reason.This means, the directory exists and is writable, the disk is not full.
I am now storing the content in a database table. I am no longer saving it directly to the file system.