#425 Unable to use httpunit without JavaScript library

open
Wolfgang Fahl
None
5
2014-01-08
2008-12-28
Mark Ziesemer
No

I was attempting to use httpunit 1.7 under Java 1.5/5.0 for testing a servlet. Since no JavaScript is involved, I shouldn't need to include "js.jar" or otherwise include the Mozilla Rhino JavaScript engine. As implied on the httpunit FAQ, if this library is missing, JavaScript features should be disabled, without breaking httpunit.

However, I'm experiencing a NoClassDefFoundError for org/mozilla/javascript/Scriptable. The relevant stack trace is attached. It seems to point to something within the static initialization of com.meterware.httpunit.ParsedHTML.<clinit>(ParsedHTML.java:724) eventually attempting to load "org.mozilla.javascript.Scriptable".

The error can simply be reproduced by initializing ParsedHTML by calling the only publicly accessible static method: ParsedHTML.isWebLink(null).

Also somewhat related: During initializing, the following is output to stderr: "Rhino classes (js.jar) not found - Javascript disabled". An option should be made available to expect this configuration and disable the warning. Alternatively, utilize a logging framework e.g. SLF4J or JDK1.4's logging to log this warning instead of writing to stderr.

Discussion

  • Wolfgang Fahl
    Wolfgang Fahl
    2009-08-19

    If you have a fix for this, I would be very happy to incorporate
    it. Please include a test case or instructions for duplicating
    the problem.

     
  • Wolfgang Fahl
    Wolfgang Fahl
    2009-08-19

    • assigned_to: nobody --> wolfgang_fahl
     
  • Wolfgang Fahl
    Wolfgang Fahl
    2009-08-19

    Dear Mark,

    thank you for pointing this out. Unfortunately our developer resources are limited. If you have a fix and some testCase (in your case it would probably be some kind of commandline call of httpunit with setting the classpath) I'll happily commit the result.

    Thanks for your support.

    Yours
    Wolfgang

     
  • Tom Eicher
    Tom Eicher
    2014-01-02

    For me, this different ClassNotFounds, for
    java.lang.LinkageError: Failed to link com/meterware/httpunit/dom/AbstractDomComponent
    and also for HTMLControl.
    This is very bad.
    Also, nowadys it's hard to come up with a matching JTidy version...

     
  • Russell Gold
    Russell Gold
    2014-01-02

    The latest version of httpunit now uses Maven to manage its dependencies. I would advise upgrading to deal with the parser issue (although I'd recommend using NekoHtml, which should be the default).

    The linkage error is the result of reworking the classes several years ago to simplify the Javascript implementation. It is no longer possible to work without Rhino, as the various object classes now extend Rhino classes. The documentation would need to be fixed.

     
  • Tom Eicher
    Tom Eicher
    2014-01-02

    Thanks Russell.
    Actually, I am looking at httpunit at mavenhub.com now.
    Still, this will add some really old dependencies to any project...

     
  • Russell Gold
    Russell Gold
    2014-01-08

    Ah, now that is useful information. When I started down this path several years ago, I had expected to have time to address incompatibilities and ultimately keep up with Rhino releases or whatever will replace it. Not sure how much time I have to give to this, but if you have ideas on how to move forward, I'd be happy to work with you.