You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jason van Zyl <ja...@zenplex.com> on 2002/09/13 02:07:18 UTC
Re: [Patch ??] [Jelly] java.lang.ClassCastException when using
dynamic tags inside a loop
On Wed, 2002-09-11 at 17:57, Guido Schmutz wrote:
> Hi,
>
> In the meantime I was able to debug the problem below and I've tracked it down to the method run in the class StaticTagScript. In the following line, the variable tag holds a DynamicTag and not a StaticTag inside a loop (step >= 2), causing the ClassCastException
>
> tag = findDynamicTag(context, (StaticTag) tag);
>
> With a instanceof check, the Exception can be avoided:
>
> if (! (tag instanceof DynamicTag)) {
> tag = findDynamicTag(context, (StaticTag) tag);
> }
>
> I know that's not the right way to send patches, but I'm new to Jakarta projects and CVS and I first have to learn how to do diffs. Additionally I'm also not sure, if I'm really fixing the problem or if my script is not ok.
Patch applied with a slight modification. Thanks.
> Thanks for your help
> Guido
>
>
> -----Ursprüngliche Nachricht-----
> Von: Guido Schmutz
> Gesendet: Mi 11.09.2002 17.53 h
> An: commons-dev@jakarta.apache.org
> Cc:
> Betreff: [Jelly] java.lang.ClassCastException when using dynamic tags inside a loop
>
>
> Hi,
>
> I'm getting the following exception
>
> Caught exception: java.lang.ClassCastException: org.apache.commons.jelly.impl.DynamicTag
> java.lang.ClassCastException: org.apache.commons.jelly.impl.DynamicTag
> at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:113)
> at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:134)
> at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:190)
> at org.apache.commons.jelly.tags.core.WhitespaceTag.doTag(WhitespaceTag.java:94)
> at org.apache.commons.jelly.impl.BeanTagScript.run(BeanTagScript.java:180)
> at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:134)
> at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:190)
> at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:176)
> at org.apache.commons.jelly.impl.BeanTagScript.run(BeanTagScript.java:180)
> at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:134)
> at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:190)
> at org.apache.commons.jelly.tags.core.JellyTag.doTag(JellyTag.java:100)
> at org.apache.commons.jelly.impl.BeanTagScript.run(BeanTagScript.java:180)
> at org.apache.commons.jelly.Jelly.main(Jelly.java:128)
>
> when executing the following Jelly Script:
>
> <?xml version="1.0"?>
> <j:jelly xmlns:j="jelly:core"
> xmlns:b="jelly:betwixt"
> xmlns:x="jelly:xml"
> xmlns:log="jelly:log"
> xmlns:define="jelly:define"
> xmlns:u="tvdUtil">
>
> <define:taglib uri="tvdUtil" trim="true">
> <define:tag name="sep" trim="true">
> <j:choose>
> <j:when test="${index == 1}">${first}</j:when>
> <j:otherwise>${next}</j:otherwise>
> </j:choose></define:tag>
>
> </define:taglib>
>
> <j:forEach begin="1" end="3" indexVar="i">
> <j:whitespace trim="false">
> <u:sep first=";" next="," index="${i}"/> index ${i}
> </j:whitespace>
> </j:forEach>
> </j:jelly>
>
> This exception only happens, when there is more than one step in the loop (end > 2).
>
> I'm new to Jelly, is there a problem in my script or is it a bug ?
>
> Thanks for your help
> Guido
>
> I
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>