I want to login https://pacer.login.uscourts.gov/csologin/login.jsf. i have used html unit for submitting a login form. here is my code:
public void submittingForm() throws Exception {
final WebClient webClient = new WebClient();
// Get the first page
final HtmlPage page1 = webClient.getPage("https://pacer.login.uscourts.gov/csologin/login.jsf");
// Get the form that we are dealing with and within that form,
// find the submit button and the field that we want to change.
final HtmlForm form = page1.getFormByName("login");
// final HtmlSubmitButton button = form.getButtonByName("login:j_idt184");
final HtmlTextInput textField = form.getInputByName("login:loginName");
final HtmlTextInput textField1 = form.getInputByName("login:password");
// Change the value of the text field
textField.setValueAttribute("XXX");
textField1.setValueAttribute("XXX");
// Now submit the form by clicking the button and get back the second page.
final HtmlPage page2 = form.getButtonByName("login:j_idt184").click();
System.out.println(page2.asText());
webClient.closeAllWindows();
}
But it coutinue showing same error:
Exception in thread "main" java.lang.IllegalAccessError: class com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy$FixedSubString cannot access its superclass net.sourceforge.htmlunit.corejs.javascript.regexp.SubString
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.makeContext(HtmlUnitContextFactory.java:227)
at net.sourceforge.htmlunit.corejs.javascript.Context.enter(Context.java:439)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:535)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(JavaScriptEngine.java:157)
at com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1141)
at com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImpl.java:109)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:200)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:179)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:221)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:106)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:433)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:358)
at htmlunit.HtmlUnit.submittingForm(HtmlUnit.java:63)
at htmlunit.HtmlUnit.main(HtmlUnit.java:28)
Java Result: 1
how to overcome above error and successfull login to above url.i am using following jar in my code: htmlunit2.9jar,commons-code.jar,etc. which jar need to avoid above error.
please provide your suggestion.
thanks
atul
The HtmlUnit installation I have on my system includes both htmlunit-2.15.jar (let's call this the "main" JAR) and htmlunit-core-js-2.15.jar (let's call this the "corejs" JAR). Looking inside the two JARs, I can see that the main JAR has
com.gargoylesoftware.htmlunit.javascript.regexp.*
, while the corejs JAR hasnet.sourceforge.htmlunit.corejs.javascript.regexp.*
:So I suspect that you are successfully including the main JAR in your $CLASSPATH, but not the corejs JAR. Thus, to solve the problem, you have to find the corejs JAR and include it in your $CLASSPATH.
Normally, once installed, these two JARs will live in the same directory. So, if this is the case for you, it will probably be easier for you to use the wildcard syntax in the $CLASSPATH to get both of them in one shot.