java.lang.NoSuchMethodError: org.jdom.Element: method getParent()Lorg/jdom/Element

Discussion in 'Java' started by Tinker, Oct 6, 2005.

  1. Tinker

    Tinker Guest

    Hi,

    I have a question re. JDOM 1.0 (http://www.jdom.org) ... specifically
    relating to the getParent method used from the Element object.

    JDOM 1.0 release dated 9th September 2004 (http://www.jdom.org/dist/binary/)

    The JavaDoc for JDOM 1.0 (http://www.jdom.org/docs/apidocs/index.html)
    indicates that the org.jdom.Element class is a subclass of org.jdom.Content
    and that the getParent method is inherited from org.jdom.Content.

    I checked the getParent method, which is indeed a method of
    org.jdom.Content.

    Any idea why calling...

    Element testParent = (Element)testElement.getParent();

    .... (where testElement is an Element object) might throw a
    java.lang.NoSuchMethodError exception(?)...

    Exception in thread "main" java.lang.NoSuchMethodError: org.jdom.Element:
    method getParent()Lorg/jdom/Element; not found

    Cheers,
    Paul

    Aside: please advise if there is a more appropriate group to post - thanks
    Tinker, Oct 6, 2005
    #1
    1. Advertising

  2. Tinker

    Harry Bosch Guest

    Hmm. Are you sure that this javadoc is correct? Perhaps the method
    was moved down the chain and the javadoc is out of date.

    Perhaps you are importing the wrong type of element?

    Could you do a getClass().getName() and see what it is?
    Harry Bosch, Oct 6, 2005
    #2
    1. Advertising

  3. Tinker

    Harry Bosch Guest

    FYI, I just looked at the JDOM source and it that method does exist in
    the Content superclass. So, it should be there. My guess is that your
    importing the wrong class for Element. I have a feeling you are
    importing an org.w3c.dom.Element.
    Harry Bosch, Oct 6, 2005
    #3
  4. Tinker

    Ross Bamford Guest

    On Thu, 06 Oct 2005 14:06:52 +0100, Tinker <>
    wrote:

    > Hi,
    >
    > I have a question re. JDOM 1.0 (http://www.jdom.org) ... specifically
    > relating to the getParent method used from the Element object.
    >
    > JDOM 1.0 release dated 9th September 2004
    > (http://www.jdom.org/dist/binary/)
    >
    > The JavaDoc for JDOM 1.0 (http://www.jdom.org/docs/apidocs/index.html)
    > indicates that the org.jdom.Element class is a subclass of
    > org.jdom.Content
    > and that the getParent method is inherited from org.jdom.Content.
    >
    > I checked the getParent method, which is indeed a method of
    > org.jdom.Content.
    >
    > Any idea why calling...
    >
    > Element testParent = (Element)testElement.getParent();
    >
    > ... (where testElement is an Element object) might throw a
    > java.lang.NoSuchMethodError exception(?)...
    >
    > Exception in thread "main" java.lang.NoSuchMethodError: org.jdom.Element:
    > method getParent()Lorg/jdom/Element; not found
    >
    > Cheers,
    > Paul
    >
    > Aside: please advise if there is a more appropriate group to post -
    > thanks
    >
    >


    I'm not sure it's entirely on-topic, but in fact the error is entirely
    correct - according to the 1.0 API there is no method on Element with the
    signature 'org.jdom.Element getParent()'. There is a 'org.jdom.Element
    getParentElement()' method with that signature, but 'getParent' returns a
    superinterface of Element, which doesn't count as far as this problem is
    concerned.

    What interests me is that this shouldn't have happened. getParent()
    returns a 'Parent', an interface which 'Element' implements, so the cast
    looks like it should have been fine, and even if not it shouldn't have
    given this exception _at all_. Maybe I'm missing something in the rest of
    the code, or in JDOM (I've only scanned the API myself), but it's odd, as
    if that your call has been linked against the wrong method during
    compilation. Is this compiled with javac?

    I suppose it could be a version issue, with two versions of the JDOM jar
    (or classes) on the classpath. Alternatively, if you're using
    instrumentation or proxy classes, for example, the method signature may
    have been changed at runtime.

    A third alternative (though unlikely in this case I think) is that your
    copy of the JDOM jar is corrupted, though I'd expect more colourful errors
    than this nasty in that case.

    Other than that, more information is needed. Where does testElement come
    from? Is it made in your code, or does it originate inside JDOM? It the
    method call you showed the actual invocation, or a paraphrase for
    something else (e.g reflection)? Was it definitely NoSuchMethodError and
    not NoSuchMethodException?

    --
    Ross Bamford ()
    Ross Bamford, Oct 8, 2005
    #4
  5. Tinker

    Harry Bosch Guest

    I am curious to know if there has been a resolution to the problem.
    Has there been?
    Harry Bosch, Oct 9, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wendy S
    Replies:
    1
    Views:
    6,332
    Darren Davison
    Aug 5, 2003
  2. Bernd Oninger
    Replies:
    4
    Views:
    12,207
    GIMME
    Jun 21, 2004
  3. Praveen Chhangani

    Converting a org.jdom DOC to org.w3c DOC

    Praveen Chhangani, Aug 5, 2003, in forum: XML
    Replies:
    2
    Views:
    951
    Johannes Koch
    Aug 7, 2003
  4. Bernd Oninger
    Replies:
    3
    Views:
    2,864
    GIMME
    Jun 21, 2004
  5. Replies:
    1
    Views:
    2,119
    Irmen de Jong
    Jun 22, 2004
Loading...

Share This Page