You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Dan Finkelstein <da...@emind.com> on 2001/07/24 21:27:36 UTC

VM_PERM_INLINE_LOCAL issue

Geir,

This bug was really hard to debug -- I haven't been able to reproduce it in 
a small test case, but here is the essence:

We process our templates through the velocity engine again and again until 
there is nothing that is substituted -- this allows us to expand an 
expansion, so to speak.  Now, we also have a method, called text(), which 
we put into the context, and it looks something like this:

         public String text(String lookup)
                 throws Exception
         {
                 String text = getLookup(lookup);
                 for (;;) {

                         String nextText = ppEvaluate(text, text,context);

                         if (nextText.equals(text))
                                 break;

                         text = nextText;
                 }

                 return text;
         }

where the ppEvaluate() method just calls Velocities evaluate() again and 
again -- usually twice -- until no substitutions are made.  There was a 
case where lookup returned a text string that had length of zero, and the 
stacktrace in velocity log showed up -- this only happened if 
VM_PERM_INLINE_LOCAL  was set to true.

Geir, I wasn't able to reproduce this in a standalone program.  Hopefully, 
this datapoint if enough to understand what is going on!!

Sorry this couldn't have been more complete,
Dan


At 07:42 PM 7/23/01 -0400, you wrote:
>Whoops :)
>
>Can you send me the template?
>
>geir
>
>Dan Finkelstein wrote:
> >
> > I've been trying to tune the runtime behavior of the velocimacro
> > system.  By just adding this line,
> >
> >         velocityEngine.setProperty(velocityEngine.VM_PERM_INLINE_LOCAL, 
> "true");
> >
> >   the velocity.log file would contain the below stacktrace.  We're using
> > the latest Vel 1.2 dev jar, along with one macro library which is loaded on
> > initialization.  We also include macros in templates.  I'm not sure if this
> > info helps, but it might be pertinent.  Can you give me some idea what to
> > do to isolate this problem?
> >
> > Thanks again,
> > Dan
> >
> > Mon Jul 23 15:52:12 PDT 2001  [error] Parser Error:
> > C:\projects\gusa/builds/common/b0/templates/External.html :
> > java.lang.NullPointerException
> >         at
> > 
> org.apache.velocity.runtime.VelocimacroManager.get(VelocimacroManager.java:181)
> >         at
> > 
> org.apache.velocity.runtime.VelocimacroFactory.isVelocimacro(VelocimacroFactory.java:363)
> >         at
> > 
> org.apache.velocity.runtime.VelocimacroFactory.getVelocimacro(VelocimacroFactory.java:378)
> >         at
> > 
> org.apache.velocity.runtime.RuntimeInstance.getVelocimacro(RuntimeInstance.java:933)
> >         at 
> org.apache.velocity.runtime.parser.Parser.Directive(Parser.java:601)
> >         at 
> org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:306)
> >         at 
> org.apache.velocity.runtime.parser.Parser.process(Parser.java:247)
> >         at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:103)
> >         at 
> org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:667)
> >         at 
> org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:611)
> >         at 
> org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:324)
> >         at 
> org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:254)
> >         at 
> com.yipinet.b0.preprocess.ProcessTags.ppEvaluate(ProcessTags.java:264)
> >         at 
> com.yipinet.b0.preprocess.ProcessTags.<init>(ProcessTags.java:182)
> >         at com.yipinet.b0.build.go.processLesson(go.java:644)
> >         at com.yipinet.b0.build.go.doit(go.java:288)
> >         at com.yipinet.b0.build.go.main(go.java:77)
> >         at com.yipinet.b0.build.dgo.main(dgo.java:56)
> >         at java.lang.reflect.Method.invoke(Native Method)
> >         at com.yipinet.go.execStatic(go.java:275)
> >         at com.yipinet.go.execMain(go.java:253)
> >         at com.yipinet.go.launchGo(go.java:225)
> >         at com.yipinet.dgo.main(dgo.java:66)
> > Dan Finkelstein
> > Senior Architect, Instructional Tools & Technology
> > eMind LLC
> > Northern California Annex
> > 1250 Addison St, Suite #210
> > Berkeley, CA 94702-1700
> > Tel: (510) 486-2740
> > Fax: (510)486-2843
> >
> > Visit us at <http://www.emind.com/>
> >
> > This email message is for the sole use of the intended recipient(s) and may
> > contain confidential and privileged information. Any unauthorized review,
> > use, disclosure or distribution is prohibited. If you are not the intended
> > recipient, please contact the sender by reply email and destroy all copies
> > of the original message.
>
>--
>Geir Magnusson Jr.                           geirm@optonline.net
>System and Software Consulting
>Developing for the web?  See http://jakarta.apache.org/velocity/
>Be well, do good work, and keep in touch.

Dan Finkelstein
Senior Architect, Instructional Tools & Technology
eMind LLC
Northern California Annex
1250 Addison St, Suite #210
Berkeley, CA 94702-1700
Tel: (510) 486-2740
Fax: (510)486-2843

Visit us at <http://www.emind.com/>

This email message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


Re: VM_PERM_INLINE_LOCAL issue

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Nope, that's good.  Shouldn't be hard to find.  Thanks for looking into
it.

geir

Dan Finkelstein wrote:
> 
> Geir,
> 
> This bug was really hard to debug -- I haven't been able to reproduce it in
> a small test case, but here is the essence:
> 
> We process our templates through the velocity engine again and again until
> there is nothing that is substituted -- this allows us to expand an
> expansion, so to speak.  Now, we also have a method, called text(), which
> we put into the context, and it looks something like this:
> 
>          public String text(String lookup)
>                  throws Exception
>          {
>                  String text = getLookup(lookup);
>                  for (;;) {
> 
>                          String nextText = ppEvaluate(text, text,context);
> 
>                          if (nextText.equals(text))
>                                  break;
> 
>                          text = nextText;
>                  }
> 
>                  return text;
>          }
> 
> where the ppEvaluate() method just calls Velocities evaluate() again and
> again -- usually twice -- until no substitutions are made.  There was a
> case where lookup returned a text string that had length of zero, and the
> stacktrace in velocity log showed up -- this only happened if
> VM_PERM_INLINE_LOCAL  was set to true.
> 
> Geir, I wasn't able to reproduce this in a standalone program.  Hopefully,
> this datapoint if enough to understand what is going on!!
> 
> Sorry this couldn't have been more complete,
> Dan
> 
> At 07:42 PM 7/23/01 -0400, you wrote:
> >Whoops :)
> >
> >Can you send me the template?
> >
> >geir
> >
> >Dan Finkelstein wrote:
> > >
> > > I've been trying to tune the runtime behavior of the velocimacro
> > > system.  By just adding this line,
> > >
> > >         velocityEngine.setProperty(velocityEngine.VM_PERM_INLINE_LOCAL,
> > "true");
> > >
> > >   the velocity.log file would contain the below stacktrace.  We're using
> > > the latest Vel 1.2 dev jar, along with one macro library which is loaded on
> > > initialization.  We also include macros in templates.  I'm not sure if this
> > > info helps, but it might be pertinent.  Can you give me some idea what to
> > > do to isolate this problem?
> > >
> > > Thanks again,
> > > Dan
> > >
> > > Mon Jul 23 15:52:12 PDT 2001  [error] Parser Error:
> > > C:\projects\gusa/builds/common/b0/templates/External.html :
> > > java.lang.NullPointerException
> > >         at
> > >
> > org.apache.velocity.runtime.VelocimacroManager.get(VelocimacroManager.java:181)
> > >         at
> > >
> > org.apache.velocity.runtime.VelocimacroFactory.isVelocimacro(VelocimacroFactory.java:363)
> > >         at
> > >
> > org.apache.velocity.runtime.VelocimacroFactory.getVelocimacro(VelocimacroFactory.java:378)
> > >         at
> > >
> > org.apache.velocity.runtime.RuntimeInstance.getVelocimacro(RuntimeInstance.java:933)
> > >         at
> > org.apache.velocity.runtime.parser.Parser.Directive(Parser.java:601)
> > >         at
> > org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:306)
> > >         at
> > org.apache.velocity.runtime.parser.Parser.process(Parser.java:247)
> > >         at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:103)
> > >         at
> > org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:667)
> > >         at
> > org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:611)
> > >         at
> > org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:324)
> > >         at
> > org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:254)
> > >         at
> > com.yipinet.b0.preprocess.ProcessTags.ppEvaluate(ProcessTags.java:264)
> > >         at
> > com.yipinet.b0.preprocess.ProcessTags.<init>(ProcessTags.java:182)
> > >         at com.yipinet.b0.build.go.processLesson(go.java:644)
> > >         at com.yipinet.b0.build.go.doit(go.java:288)
> > >         at com.yipinet.b0.build.go.main(go.java:77)
> > >         at com.yipinet.b0.build.dgo.main(dgo.java:56)
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at com.yipinet.go.execStatic(go.java:275)
> > >         at com.yipinet.go.execMain(go.java:253)
> > >         at com.yipinet.go.launchGo(go.java:225)
> > >         at com.yipinet.dgo.main(dgo.java:66)
> > > Dan Finkelstein
> > > Senior Architect, Instructional Tools & Technology
> > > eMind LLC
> > > Northern California Annex
> > > 1250 Addison St, Suite #210
> > > Berkeley, CA 94702-1700
> > > Tel: (510) 486-2740
> > > Fax: (510)486-2843
> > >
> > > Visit us at <http://www.emind.com/>
> > >
> > > This email message is for the sole use of the intended recipient(s) and may
> > > contain confidential and privileged information. Any unauthorized review,
> > > use, disclosure or distribution is prohibited. If you are not the intended
> > > recipient, please contact the sender by reply email and destroy all copies
> > > of the original message.
> >
> >--
> >Geir Magnusson Jr.                           geirm@optonline.net
> >System and Software Consulting
> >Developing for the web?  See http://jakarta.apache.org/velocity/
> >Be well, do good work, and keep in touch.
> 
> Dan Finkelstein
> Senior Architect, Instructional Tools & Technology
> eMind LLC
> Northern California Annex
> 1250 Addison St, Suite #210
> Berkeley, CA 94702-1700
> Tel: (510) 486-2740
> Fax: (510)486-2843
> 
> Visit us at <http://www.emind.com/>
> 
> This email message is for the sole use of the intended recipient(s) and may
> contain confidential and privileged information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message.

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
Be well, do good work, and keep in touch.