• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help using htmlunit

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep getting this error when trying to run just a simple test program.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/parsers/AbstractSAXParser
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:214)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:431)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389)

I can't seem to find help on this subject anywhere.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds as if you have no, or a wrong version of, Jakarta Xerces in the classpath.
 
Kris Bauer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java -cp .:commons-beanutils-1.7.0.jar:commons-cli-1.0.jar:commons-codec-1.3.jar:commonc-collections-3.2.jar:commons-httpclient-3.0.1.jar:commons-io-1.2.jar:commons-jelly-1.0.jar:commons-jelly-tags-log-1.0.jar:commons-jexl-1.0.jar:commons-lang-2.1.jar:commons-logging-1.1.jar :dom4j-1.6.1.jar:htmlunit-1.9.jar:jaxen-1.1-beta-9.jar:js-1.6R2.jar:nekohtml-0.9.5.jar:xerceslmpl-2.6.2.jar:xmlParserAPIs-2.6.2.jar

That's my classpath. I'm running this on a Mac, if that makes any difference.
[ August 03, 2006: Message edited by: Kris Bauer ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to move this to our "Testing" forum.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you see the class "org/apache/xerces/parsers/AbstractSAXParser.class" inside "xerceslmpl-2.6.2.jar"? If not, then you probably should use whatever version of Xerces HtmlUnit comes with.

Oh, and when your classpath looks like this:

Originally posted by Kris Bauer:
java -cp .:commons-beanutils-1.7.0.jar:commons-cli-1.0.jar:commons-codec-1.3.jar:commonc-collections-3.2.jar:commons-httpclient-3.0.1.jar:commons-io-1.2.jar:commons-jelly-1.0.jar:commons-jelly-tags-log-1.0.jar:commons-jexl-1.0.jar:commons-lang-2.1.jar:commons-logging-1.1.jar om4j-1.6.1.jar:htmlunit-1.9.jar:jaxen-1.1-beta-9.jar:js-1.6R2.jar:nekohtml-0.9.5.jar:xerceslmpl-2.6.2.jar:xmlParserAPIs-2.6.2.jar


all those .jar files should reside in the current working directory where you're invoking the JVM. Is that true in your case?
 
Kris Bauer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would I check to see if the xerces jar contains that file?
It is the version that came with htmlunit.

And all of those jars are where the java file is.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kris Bauer:
How would I check to see if the xerces jar contains that file?



jar files are basically zip files ,so you can use any zip utility you want.


It is the version that came with htmlunit.



Then it should probably be ok.


And all of those jars are where the java file is.



Using your command line, they need to be in the folder you are starting the command from. You would be save if you used absolute paths.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kris Bauer:
How would I check to see if the xerces jar contains that file?


As Ilja already mentioned, JAR files are just ZIP files that contain some special files for the JVM to interpret so you can use any archive management software that supports ZIP. If you're using Windows, WinZip or WinRAR would be examples of such software.

Having said that, you can also use the command line for figuring out a JAR file's content:
 
Kris Bauer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked the jar file and it contains the AbstractSAXParser.class file.
How would I go about doing the absolute paths?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kris Bauer:
How would I go about doing the absolute paths?


Instead of having your classpath say "file1;file2;file3", make it say "c:\path\to\file1;c:\path\to\file2;c:\path\to\file3".
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic