You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tim Colson <tc...@cisco.com> on 2004/09/30 05:51:24 UTC
ViewRender tool - bug?
> http://jakarta.apache.org/velocity/tools/view/ViewRenderTool.html
>
> Lol. Thanks dude. I can't believe how pathetic I am to not
> have noticed that. ;-)
Interesting... I swapped in the ViewRenderTool...
The generic.RenderTool works fine:
<tool>
<key>render</key>
<scope>application</scope>
<class>org.apache.velocity.tools.generic.RenderTool</class>
</tool>
I changed to this:
<tool>
<key>render</key>
<scope>application</scope>
<class>org.apache.velocity.tools.view.tools.ViewRenderTool</class>
</tool>
And I get a Digester error (below), which sounds like bad XML... but the XML
looks okay to me.
Looking closer -- I see that the example on the web-page has scope==request.
When I modify the XML snippet, it works fine. So apparently the tool doesn't
like being in App scope? If so -- kind of ugly error mesg for that.
Just curious what's going on here?
Timo
ERROR [main] [2004-09-29 20:32:20,763]
[org.apache.commons.digester.Digester]- End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:252)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)
at org.apache.commons.digester.Rule.end(Rule.java:276)
at
org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at
org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator
.java:1550)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1204)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at
org.apache.velocity.tools.view.XMLToolboxManager.load(XMLToolboxManager.java
:148)
at
org.apache.velocity.tools.view.servlet.ServletToolboxManager.getInstance(Ser
vletToolboxManager.java:172)
at
org.apache.velocity.tools.view.servlet.VelocityViewServlet.initToolbox(Veloc
ityViewServlet.java:231)
at
org.apache.velocity.tools.view.servlet.VelocityViewServlet.init(VelocityView
Servlet.java:174)
at
org.apache.velocity.tools.view.servlet.VelocityLayoutServlet.init(VelocityLa
youtServlet.java:147)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:91
8)
at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:810)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:
3279)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3421)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
at
org.apache.catalina.core.StandardService.start(StandardService.java:388)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
Caused by: java.lang.ClassCastException
at
org.apache.velocity.tools.view.tools.ViewRenderTool.init(ViewRenderTool.java
:99)
at
org.apache.velocity.tools.view.ViewToolInfo.getInstance(ViewToolInfo.java:13
3)
at
org.apache.velocity.tools.view.servlet.ServletToolboxManager.addTool(Servlet
ToolboxManager.java:284)
... 37 more
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: ViewRender tool - bug?
Posted by Nathan Bubna <na...@esha.com>.
Nathan Green said:
> For a tool to use at the application level, use RenderTool. The other
> Nathan (Bubna)'s javadoc comments are pretty explicit in both tools,
> though they are sort of a footnote... Perhaps the following change
> could be made to ViewRenderTool?
>
> public void init(Object obj)
> {
> try {
> context = (Context) obj;
> } catch (ClassCastException cce) {
> throw new ClassCastException (
> "ViewRenderTool cannot initialize: "
> + "scope in toolbox config may be invalid"
> + System.getProperty("line.separator") +
> + cce.getMessage());
> }
> }
yeah, this is an understandable and easy error to make (using ViewRenderTool
in application scope), and this (or something like it) would certainly make
the error message more intelligible.
> I have not tested the above code, so I may have screwed something up.
> HTH,
no worries. i'll probably go with an instanceof check instead of a try-catch
anyway. :)
Nathan Bubna
nathan@esha.com
> Nathan
>
>
> Shinobu Kawai wrote:
>
> > Hi Timo,
> >
> >
> >><tool>
> >> <key>render</key>
> >> <scope>application</scope>
> >> <class>org.apache.velocity.tools.view.tools.ViewRenderTool</class>
> >></tool>
> >>
> >>And I get a Digester error (below), which sounds like bad XML... but the
XML
> >>looks okay to me.
> >>
> >>Looking closer -- I see that the example on the web-page has
scope==request.
> >>When I modify the XML snippet, it works fine. So apparently the tool
doesn't
> >>like being in App scope? If so -- kind of ugly error mesg for that.
> >>
> >>Just curious what's going on here?
> >
> > Take a look at
> > http://jakarta.apache.org/velocity/tools/view/
> > under "Tool Scopes". You will notice that request and session scopes
> > are set the ViewContext, whereas application scopes are set the
> > ServletContext. This causes the following to happen:
> >
> >
> >>Caused by: java.lang.ClassCastException
> >> at
>
>>org.apache.velocity.tools.view.tools.ViewRenderTool.init(ViewRenderTool.java
> >>:99)
> >
> >
> > Best regards,
> > -- Shinobu Kawai
> >
> > --
> > Shinobu Kawai <sh...@gmail.com>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
RE: ViewRender tool - bug?
Posted by Tim Colson <tc...@cisco.com>.
> For a tool to use at the application level, use RenderTool. The other
> Nathan (Bubna)'s javadoc comments are pretty explicit in both tools,
> though they are sort of a footnote... Perhaps the following change
> could be made to ViewRenderTool?
I was looking at the html doc -- it doesn't have the same footnote that I
now see is in the Javadoc.
http://jakarta.apache.org/velocity/tools/view/ViewRenderTool.html
I like the idea of the init() checking and sending some understandable error
mesg to the logs -- might be good if all tools init methods were so polite.
:-)
Thanks,
Tim
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: ViewRender tool - bug?
Posted by Nathan Green <ng...@inco5.com>.
Tim,
For a tool to use at the application level, use RenderTool. The other
Nathan (Bubna)'s javadoc comments are pretty explicit in both tools,
though they are sort of a footnote... Perhaps the following change
could be made to ViewRenderTool?
public void init(Object obj)
{
try {
context = (Context) obj;
} catch (ClassCastException cce) {
throw new ClassCastException (
"ViewRenderTool cannot initialize: "
+ "scope in toolbox config may be invalid"
+ System.getProperty("line.separator") +
+ cce.getMessage());
}
}
I have not tested the above code, so I may have screwed something up.
HTH,
Nathan
Shinobu Kawai wrote:
> Hi Timo,
>
>
>><tool>
>> <key>render</key>
>> <scope>application</scope>
>> <class>org.apache.velocity.tools.view.tools.ViewRenderTool</class>
>></tool>
>>
>>And I get a Digester error (below), which sounds like bad XML... but the XML
>>looks okay to me.
>>
>>Looking closer -- I see that the example on the web-page has scope==request.
>>When I modify the XML snippet, it works fine. So apparently the tool doesn't
>>like being in App scope? If so -- kind of ugly error mesg for that.
>>
>>Just curious what's going on here?
>
> Take a look at
> http://jakarta.apache.org/velocity/tools/view/
> under "Tool Scopes". You will notice that request and session scopes
> are set the ViewContext, whereas application scopes are set the
> ServletContext. This causes the following to happen:
>
>
>>Caused by: java.lang.ClassCastException
>> at
>>org.apache.velocity.tools.view.tools.ViewRenderTool.init(ViewRenderTool.java
>>:99)
>
>
> Best regards,
> -- Shinobu Kawai
>
> --
> Shinobu Kawai <sh...@gmail.com>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: ViewRender tool - bug?
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Timo,
> <tool>
> <key>render</key>
> <scope>application</scope>
> <class>org.apache.velocity.tools.view.tools.ViewRenderTool</class>
> </tool>
>
> And I get a Digester error (below), which sounds like bad XML... but the XML
> looks okay to me.
>
> Looking closer -- I see that the example on the web-page has scope==request.
> When I modify the XML snippet, it works fine. So apparently the tool doesn't
> like being in App scope? If so -- kind of ugly error mesg for that.
>
> Just curious what's going on here?
Take a look at
http://jakarta.apache.org/velocity/tools/view/
under "Tool Scopes". You will notice that request and session scopes
are set the ViewContext, whereas application scopes are set the
ServletContext. This causes the following to happen:
> Caused by: java.lang.ClassCastException
> at
> org.apache.velocity.tools.view.tools.ViewRenderTool.init(ViewRenderTool.java
> :99)
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org