Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java.lang.NoSuchMethodError: org.jdom.Element: method getParent()Lorg/jdom/Element

Reply
Thread Tools

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

 
 
Tinker
Guest
Posts: n/a
 
      10-06-2005
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


 
Reply With Quote
 
 
 
 
Harry Bosch
Guest
Posts: n/a
 
      10-06-2005
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?

 
Reply With Quote
 
 
 
 
Harry Bosch
Guest
Posts: n/a
 
      10-06-2005
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.

 
Reply With Quote
 
Ross Bamford
Guest
Posts: n/a
 
      10-08-2005
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 ()
 
Reply With Quote
 
Harry Bosch
Guest
Posts: n/a
 
      10-09-2005
I am curious to know if there has been a resolution to the problem.
Has there been?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
invoke a method by reflection£¬the method's parameters can not be ArrayList? jerry051 ASP .Net 2 08-02-2005 10:35 AM
BC30289: Statement cannot appear within a method body. End of method assumed. Carlos Oliveira ASP .Net 0 08-19-2004 07:51 PM
Difference between Delete method and RemoveRow method CW ASP .Net 0 04-01-2004 01:07 AM
ASP.NET: BC30289: Statement cannot appear within a method body. End of method assumed. Mike Wilmot ASP .Net 0 12-15-2003 07:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57