Form submission using html block

I want to log in https://pacer.login.uscourts.gov/csologin/login.jsf . I used the html module to submit the 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 this coutinue shows the 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 the above error and successfully log in to the system above url.i using the following jar in your code: htmlunit2.9jar, Common-code.jar, etc. which should avoid the error above.

submit your offer.

thank

Atula

+4
source share
1 answer

HtmlUnit, , htmlunit-2.15.jar( "" JAR), htmlunit-core-js-2.15.jar( "JARJ" Corejs). JAR, , JAR com.gargoylesoftware.htmlunit.javascript.regexp.*, corejs JAR net.sourceforge.htmlunit.corejs.javascript.regexp.*:

> for i in htmlunit-2.15.jar htmlunit-core-js-2.15.jar; do echo "===== $i ====="; unzip -l $i| grep regexp; done;
===== htmlunit-2.15.jar =====
        0  06-02-2014 19:53   com/gargoylesoftware/htmlunit/javascript/regexp/
      768  06-02-2014 19:53   com/gargoylesoftware/htmlunit/javascript/regexp/HtmlUnitRegExpProxy$FixedSubString.class
     1846  06-02-2014 19:53   com/gargoylesoftware/htmlunit/javascript/regexp/HtmlUnitRegExpProxy$RegExpData.class
    11530  06-02-2014 19:53   com/gargoylesoftware/htmlunit/javascript/regexp/HtmlUnitRegExpProxy.class
     1549  06-02-2014 19:53   com/gargoylesoftware/htmlunit/javascript/regexp/RegExpJsToJavaConverter$Tape.class
     3777  06-02-2014 19:53   com/gargoylesoftware/htmlunit/javascript/regexp/RegExpJsToJavaConverter.class
===== htmlunit-core-js-2.15.jar =====
        0  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/
      944  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/CompilerState.class
      712  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/GlobData.class
    42350  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/NativeRegExp.class
     6850  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/NativeRegExpCtor.class
     1077  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/REBackTrackData.class
      700  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/RECharSet.class
      819  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/RECompiled.class
     1245  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/REGlobalData.class
      687  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/RENode.class
      918  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/REProgState.class
    14443  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/RegExpImpl.class
     1072  05-30-2014 10:28   net/sourceforge/htmlunit/corejs/javascript/regexp/SubString.class

, , JAR $CLASSPATH, corejs JAR. , , corejs JAR $CLASSPATH.

, JAR . , , , , $CLASSPATH, .

+1

All Articles