-
June 1st, 2011, 10:06 PM
#1
HtmlUnit Help
This is my first post in the forum. So I would also like to say hello to all.
I am currently developing an application for Android and to do so I came across HtmlUnit.
I have never heard of HtmlUnit so I decided to try it (me being the experimental type). I have come to an impasse.
"noclassdeffounderror". Its awful because I do not fully understand it. It is my first time even seeing this error.
Code:
public void showResults(String endText) throws Exception{
WebClient webClient = new WebClient(); //ERROR IS HERE
HtmlPage page = webClient.getPage(baseSite+endText);
HtmlTable resultsT = page.getHtmlElementById("results");
int i = 0;
for(final HtmlTableRow row : resultsT.getRows()){
Toast.makeText(getApplicationContext(), "Getting Results...", Toast.LENGTH_SHORT).show();
for(final HtmlTableCell cell : row.getCells()){
results[i] = cell.asText();
i++;
}
}
}
What did I do wrong?
-
June 2nd, 2011, 07:25 AM
#2
Re: HtmlUnit Help
Do you get the error when compiling or executing?
Can you copy the full text of the message here?
Norm
-
June 2nd, 2011, 02:53 PM
#3
Re: HtmlUnit Help
I get the error while executing. There is no error while compiling. Thats why I am confused.
Full error:
Code:
06-02 19:52:47.285: ERROR/AndroidRuntime(211): Uncaught handler: thread main exiting due to uncaught exception
06-02 19:52:47.325: ERROR/AndroidRuntime(211): java.lang.NoClassDefFoundError: com.gargoylesoftware.htmlunit.WebClient
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.laytproducts.songmaster.mainAct.showResults(mainAct.java:109)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.laytproducts.songmaster.mainAct$1.onClick(mainAct.java:90)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.View.performClick(View.java:2364)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.View.onTouchEvent(View.java:4179)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.widget.TextView.onTouchEvent(TextView.java:6541)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.View.dispatchTouchEvent(View.java:3709)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.os.Looper.loop(Looper.java:123)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at android.app.ActivityThread.main(ActivityThread.java:4363)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at java.lang.reflect.Method.invokeNative(Native Method)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at java.lang.reflect.Method.invoke(Method.java:521)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-02 19:52:47.325: ERROR/AndroidRuntime(211): at dalvik.system.NativeStart.main(Native Method)
By the way, thanks for the reply.
-
June 2nd, 2011, 02:57 PM
#4
Re: HtmlUnit Help
NoClassDefFoundError: com.gargoylesoftware.htmlunit.WebClient
Do you have the above listed class in a jar file that is on the classpath?
Norm
-
June 2nd, 2011, 03:44 PM
#5
Re: HtmlUnit Help
I have it in a library labeled HtmlUnit.
So yes.
Pic just to make sure:
-
June 2nd, 2011, 03:48 PM
#6
Re: HtmlUnit Help
Some how the JVM is saying it can't find the class???
Norm
-
June 2nd, 2011, 03:51 PM
#7
Re: HtmlUnit Help
Yeah I am confused as well.
-
June 4th, 2011, 02:45 PM
#8
Re: HtmlUnit Help
No one can help me? :P
--bump--
-
June 4th, 2011, 03:00 PM
#9
Re: HtmlUnit Help
Is the jar file with the missing class on the classpath?
Add something like the following to the main method to show what the classpath is.
Use the log or where ever you output debug info to output it vs println
Code:
System.out.println("Classpath: " + System.getenv("classpath")
+ "\n java.class.path=" + props.getProperty("java.class.path") );
Norm
-
June 4th, 2011, 06:50 PM
#10
Re: HtmlUnit Help
Ok will do so.
Also noticed this in the beginning of my debug:
Code:
06-04 23:49:56.671: ERROR/dalvikvm(224): Could not find class 'com.gargoylesoftware.htmlunit.WebClient', referenced from method com.laytproducts.songmaster.mainAct.showResults
06-04 23:49:56.671: WARN/dalvikvm(224): VFY: unable to resolve new-instance 14 (Lcom/gargoylesoftware/htmlunit/WebClient;) in Lcom/laytproducts/songmaster/mainAct;
also, this is the results:
Code:
06-04 23:49:56.901: INFO/System.out(224): Classpath: null
06-04 23:49:56.901: INFO/System.out(224): java.class.path=null
of this:
Code:
Properties props = new Properties();
System.out.println("Classpath: " + System.getenv("classpath")
+ "\n java.class.path=" + props.getProperty("java.class.path") );
-
June 4th, 2011, 07:21 PM
#11
Re: HtmlUnit Help
You need to set the classpath to include your jars and the directory containing your package root.
An excellent plumber is infinitely more admirable than an incompetent philosopher. The society that scorns excellence in plumbing because plumbing is a humble activity and tolerates shoddiness in philosophy because it is exalted activity will have neither good plumbing or good philosophy. Neither its pipes or its theories will hold water...
J. Gardner
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
June 4th, 2011, 07:29 PM
#12
Re: HtmlUnit Help
How do you put a class on the classpath in the Android environment?
Norm
-
June 5th, 2011, 02:37 PM
#13
Re: HtmlUnit Help
Originally Posted by Norm
How do you put a class on the classpath in the Android environment?
I couldn't say - I guess they all have to go into the .apk file, but how that's done probably depends on your IDE. I've yet to dabble in Android development.
This may be some help: My Life With Android - Jars on the classpath
We make the road, others will make the journey...
V. Hugo
Last edited by dlorde; June 5th, 2011 at 02:39 PM.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|