[jdom-interest] ClassCastException on Element.getContent

Mattias J mattias.jiderhamn at expertsystems.se
Sun Feb 12 06:53:37 PST 2006


Instead of casting it, do getClass() on the Object and post the class name on the list.

  Object o = ...;
  System.out.println(o.getClass().getName());

At 13:51 2006-02-12, you wrote:
>It is possible that the production environment contains another version of
>the jdom jar, I'll investigate that. The stack trace tells me nothing
>about what type I actually have, strangely enough, just
>java.lang.ClassCastException at [method/class/row] ...
>
>
>
>> Jason Hunter wrote:
>>
>>
>>>> where xhtmlElement is of type org.jdom.Element. This works nicely in
>>>> the
>>>> test environment, but in the production environment the second line
>>>> (Contents contents = ...) causes a ClassCastException. Both
>>>> environments
>>>> run sun jdk 1.4. Under what circumstances could the returned list from
>>>> getContents() contain anything that is not castable to Content?
>>
>> Any chance the production environment is a servlet container that
>> contains a different version of jdom.jar?
>>
>> What type do you actually have? What does the stack trace tell you?




More information about the jdom-interest mailing list