1

So I'm trying to do parsing of a javascript generated resource on the server side for SEO optimization. I'm following the example of using HTMLUnit on a java based server that google provides here.

We're currently hosted using app-engine but I'm finding when calling

final WebClient webClient = new WebClient();

I always receive this exception, anyone have any ideas:

java.lang.ArrayStoreException: com.gargoylesoftware.htmlunit.httpclient.HtmlUnitDomainHandler
    at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitBrowserCompatCookieSpec.<init>(HtmlUnitBrowserCompatCookieSpec.java:101)
    at com.gargoylesoftware.htmlunit.CookieManager.<init>(CookieManager.java:56)
    at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:141)
    at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:202)
    at filters.CrawlServlet.doFilter(CrawlServlet.java:38)
2
  • What HtmlUnit version do you use? There is no 101 line in HtmlUnitBrowserCompatCookieSpec in 2.16 May 4, 2015 at 18:53
  • My fault, there is line 101, can you post a small test case. May 4, 2015 at 18:58

2 Answers 2

3

I tested with HtmlUnit 2.16 and AppEngine and it works here.

With a sample project, copying the 2.16 jars to war/WEB-INF/lib, and having:

@SuppressWarnings("serial")
public class GuestbookServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        resp.setContentType("text/plain");
        try (WebClient webClient = new WebClient()) {
            final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net");
            resp.getWriter().println(page.getTitleText());           
        }
    }
}
1

This should be a httpclient version dependency problem, for HTMLUnit 2.16 you should use httpclient 4.4.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.