OutOfMemoryException Processing Velocity Template

2005-05-05 Thread lawrence
I am getting an OutOfMemoryException:

org.apache.velocity.exception.MethodInvocationException: Invocation of method 
'get' in  class org.apache.velocity.tools.struts.TilesTool threw exception 
class java.lang.OutOfMemoryError : null

when I am creating a large velocity file.  The vm file itself is fairly small, 
but this piece of velocity is causing the exception:

#foreach($row in $List)
tr
td height=20 class=tbltxt$!row.item1/td
td class=tbltxt$!row.item2/td
td class=tbltxt$!row.item3/td
td class=tbltxt$!row.item4/td
td class=tbltxt$!number.format('currency', $!row.item5)/td
/tr
#end

List is a list of relatively small objects (5-6 Strings, a couple of 
BigDecimals), but the List itself contains approximately 66,000 entries.  
Unfortunately, unless I set the tomcat JVM to use a heap size of at least 256M, 
this velocity template throws an OutOfMemoryException when it is being 
processed.   

Any suggestions?

Thanks.

-L

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Ifnotnull

2005-05-05 Thread jeichels

Hey all,

I had previously upgraded to 1.5-dev and things are working well with the one 
email templating thing I had found help here on.

Since the upgrade, however, I seem to be getting some RHS of #set statement is 
null. things i don't remember getting before.

I explored a bit and found:  
http://wiki.apache.org/jakarta-velocity/CheckingForNull

I added these to my velocity property file:
   userdirective = org.apache.velocity.tools.generic.directive.Ifnull
   userdirective = org.apache.velocity.tools.generic.directive.Ifnotnull

And changed my template code as follows:
 #ifnotnull( $form )
 #set ($attr = $form.getBean())
 #end

And get this error:

Encountered #end\r\n at line 3, column 1. Was expecting one of: ( ... ... 
... ...  ... \\ ... ... ... *# ... *# ... ... ... ... ... ... ... 
... ... ... ... { ... } ... 

org.apache.velocity.exception.ParseErrorException: Encountered #end\r\n at 
line 3, column 1.
Was expecting one of:
 
( ...
 ...
 ...
 ...
 ...
\\ ...
 ...
 ...
*# ...
*# ...
 ...
 ...
 ...
 ...
 ...
 ...
 ...
 ...
 ...
 ...
{ ...
} ...

at org.apache.velocity.Template.process(Template.java:141)
at 
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:428)
at 
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:346)
at 
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:835)
at 
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:817)
at 
org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:504)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate(Unknown 
Source)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest(Unknown
 Source)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest(Unknown 
Source)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.doPost(Unknown 
Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at 
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
at 
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.velocity.tools.view.ImportSupport.acquireString(Unknown 
Source)
at org.apache.velocity.tools.struts.TilesTool.doInsert(Unknown Source)
at org.apache.velocity.tools.struts.TilesTool.doInsert(Unknown Source)
at org.apache.velocity.tools.struts.TilesTool.processUrl(Unknown Source)
at 
org.apache.velocity.tools.struts.TilesTool.processAsDefinitionOrURL(Unknown 
Source)
at 
org.apache.velocity.tools.struts.TilesTool.processObjectValue(Unknown Source)
at org.apache.velocity.tools.struts.TilesTool.get(Unknown Source)
at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at 
org.apache.velocity.runtime.parser.node.GetExecutor.execute(GetExecutor.java:65)
at 
org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:300)
at 
org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:157)
at 
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
at 
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:224)
at 
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:231)
at org.apache.velocity.Template.merge(Template.java:256)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.mergeTemplate(Unknown
 Source)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest(Unknown 
Source)
at 
org.apache.velocity.tools.view.servlet.VelocityViewServlet.doPost(Unknown 
Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at 

Re: OutOfMemoryException Processing Velocity Template

2005-05-05 Thread jian chen
Hi,

This maybe because you haven't turned on template caching. I had
similar problem before, and even if I only used evaluate(...) method
and load the template using my own java program, it happened when the
for loop is lot of iterations.

The bottom line for my problem is I need to turn on template caching,
so, velocity will not try to cache the objects it parsed during each
time of the iteration.

I did:
ri.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, true);

where ri is a runtime instance. 

Will this fix your issue?

Cheers,

Jian


On 5/5/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I am getting an OutOfMemoryException:
 
 org.apache.velocity.exception.MethodInvocationException: Invocation of method 
 'get' in  class org.apache.velocity.tools.struts.TilesTool threw exception 
 class java.lang.OutOfMemoryError : null
 
 when I am creating a large velocity file.  The vm file itself is fairly 
 small, but this piece of velocity is causing the exception:
 
 #foreach($row in $List)
 tr
 td height=20 class=tbltxt$!row.item1/td
 td class=tbltxt$!row.item2/td
 td class=tbltxt$!row.item3/td
 td class=tbltxt$!row.item4/td
 td class=tbltxt$!number.format('currency', $!row.item5)/td
 /tr
 #end
 
 List is a list of relatively small objects (5-6 Strings, a couple of 
 BigDecimals), but the List itself contains approximately 66,000 entries.  
 Unfortunately, unless I set the tomcat JVM to use a heap size of at least 
 256M, this velocity template throws an OutOfMemoryException when it is being 
 processed.
 
 Any suggestions?
 
 Thanks.
 
 -L
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]