You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Darren Davison <da...@davison.uk.net> on 2004/06/09 02:02:26 UTC

exception using ViewRenderTool

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Trying to expose a render tool with;

ViewRenderTool viewRenderTool = new ViewRenderTool();
viewRenderTool.init(velocityContext);
velocityContext.put("render", viewRenderTool);



I get the following trace every time I attempt to invoke recurse() (or eval)

org.apache.velocity.exception.MethodInvocationException: Invocation of 
method 'recurse' in  class 
org.apache.velocity.tools.view.tools.ViewRenderTool threw exception class 
java.lang.NullPointerException : null
        org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:284)
        org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:213)
        org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:258)
        org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:269)
        org.apache.velocity.Template.merge(Template.java:294)

Any pointers as to where to start looking for the cause?

Regards,
- -- 
Darren Davison
Public Key: http://www.davison.uk.net/pages/key.htm
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD4DBQFAxlOSKLMLAN01aw0RAuRcAJiVhODOys8FoQUM0m2Y1tbiIEQPAJ9oh/mu
qypkp+4W8b5/tRRBzrhAEQ==
=Iqn5
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: exception using ViewRenderTool

Posted by Nathan Bubna <na...@esha.com>.
Darren Davison said:
> On Wednesday 09 June 2004 02:29, Nathan Bubna wrote:
>
> > hmm.  looks like the recurse method will throw an NPE if the call to
> > Velocity.evalute() fails.  i'm committing a change so that will be
> > handled better, but even if i do, your recurse evalution will still be
> > broken. without knowing what you're trying to recurse on, i can't help
> > with that.
>
> I get the trace trying to do anything - including the simple examples in the
> JavaDocs for ViewRenderTool..
...

hmm.  have you init'ed Velocity before trying to use the tool?  try doing
Velocity.init() before using the tool.

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: exception using ViewRenderTool

Posted by Darren Davison <da...@davison.uk.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 09 June 2004 02:29, Nathan Bubna wrote:

> hmm.  looks like the recurse method will throw an NPE if the call to
> Velocity.evalute() fails.  i'm committing a change so that will be
> handled better, but even if i do, your recurse evalution will still be
> broken. without knowing what you're trying to recurse on, i can't help
> with that.

I get the trace trying to do anything - including the simple examples in the 
JavaDocs for ViewRenderTool..

Example of eval():
      Input
      -----
      #set( $list = [1,2,3] )
      #set( $object = '$list' )
      #set( $method = 'size()' )
      $render.eval("${object}.$method")

      Output
      ------
      3
 
 Example of recurse():
      Input
      -----
      #macro( say_hi )hello world!#end
      #set( $foo = '#say_hi()' )
      #set( $bar = '$foo' )
      $render.recurse('$bar')

      Output
      ------
      hello world!

- -- 
Darren Davison
Public Key: http://www.davison.uk.net/pages/key.htm
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAxqQTKLMLAN01aw0RApMxAJ9VcUprE1VN28UxhGduT1JJitlfRQCgnbEr
MwDhgaCqjUie27ZifdhKriQ=
=OL6S
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: exception using ViewRenderTool

Posted by Nathan Bubna <na...@esha.com>.
Darren Davison said:
> Trying to expose a render tool with;
>
> ViewRenderTool viewRenderTool = new ViewRenderTool();
> viewRenderTool.init(velocityContext);
> velocityContext.put("render", viewRenderTool);
>
> I get the following trace every time I attempt to invoke recurse() (or eval)
>
> org.apache.velocity.exception.MethodInvocationException: Invocation of
> method 'recurse' in  class
> org.apache.velocity.tools.view.tools.ViewRenderTool threw exception class
> java.lang.NullPointerException : null
>         org.apache.velocity.runtime.parser.node.ASTMethod.execute
...
> Any pointers as to where to start looking for the cause?

hmm.  looks like the recurse method will throw an NPE if the call to
Velocity.evalute() fails.  i'm committing a change so that will be handled
better, but even if i do, your recurse evalution will still be broken.
without knowing what you're trying to recurse on, i can't help with that.

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org