I am new to HtmlUnit, and really anything outside of the standard java library, and I am getting this error when I try to compile a simple program to print the contents of a webpage.
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for /Users/***/eclipse-workspace/Research/lib/xalan-2.7.2.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.bsf.BSFManager not in module
It seems to be an issue with a dependency of a dependency of HtmlUnit, but I have downloaded all of the necessary dependencies and created a reference library for my project. I tried re-downloading xalan individually but the same issue occurred.
I am using Eclipse 4.15.0, the latest java version and jdk, and I wrote this code to test if I set up HtmlUnit correctly.
import java.io.IOException;
import java.net.MalformedURLException;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class cccbdbParser {
public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException {
// TODO Auto-generated method stub
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setJavaScriptEnabled(true);
HtmlPage page = webClient.getPage("https://cccbdb.nist.gov/expgeom1x.asp");
String pageContent = page.asText();
System.out.println(pageContent);
}
}
Any advice on how to fix this issue? I haven't been able to find any documentation about this exception in HtmlUnit, it seems to work fine for others.
Edit: This answer https://stackoverflow.com/a/54682966/13521721 describes where the issue comes from, but not how to solve it. Within the JAR for the module xalan
version 2.7.2, the provider class isn't packaged within the dependency. (The package org.apache
does not continue to have the package bfs
and class BSFManager
, causing the exception). Does anyone know how to get around this?