velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Johann.We...@eventim.de>
Subject AW: Problem with VM and caching
Date Fri, 15 May 2009 16:53:16 GMT
I'm using the last one, 1.6.2.
The problem is not the macro, I was wrong.
The thing is, the file default.config is not available. In this case my IncludeEventHandler
returns null (public String includeEvent(..) method) to keep the parsing process going.
When I use the merge method with a list of macro libs, it throws a npe if the file doesn't
exist and the IncludeEventHandler returns null.


-----Ursprüngliche Nachricht-----
Von: Nathan Bubna [mailto:nbubna@gmail.com]
Gesendet: Fr 15.05.2009 18:17
An: Velocity Users List
Betreff: Re: Problem with VM and caching
 
What version of Velocity are you using?

On Fri, May 15, 2009 at 4:04 AM,  <Johann.Weber@eventim.de> wrote:
> It's a little bit strange...
> I have a #parse directive in my global lib.vm which causes an exception
>
> #macro(setGlobalConstants)
>        #set($TEST = "this is a constant var!")
>        #parse("setup/default.config")
> #end
>
> If I set velocimacro.permissions.allow.inline.local.scope = true, I'll see this exception.
If it's set to false, everything is fine.
>
> java.lang.NullPointerException
>        at java.util.Hashtable.get(Hashtable.java:333)
>        at org.apache.velocity.runtime.VelocimacroManager.getNamespace(VelocimacroManager.java:318)
>        at org.apache.velocity.runtime.VelocimacroManager.get(VelocimacroManager.java:215)
>        at org.apache.velocity.runtime.VelocimacroFactory.getVelocimacro(VelocimacroFactory.java:563)
>        at org.apache.velocity.runtime.RuntimeInstance.getVelocimacro(RuntimeInstance.java:1563)
>        at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:218)
>        at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
>        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
>        at org.apache.velocity.runtime.directive.Parse.render(Parse.java:260)
>        at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
>        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
>        at org.apache.velocity.Template.merge(Template.java:328)
>
> -----Ursprüngliche Nachricht-----
> Von: Nathan Bubna [mailto:nbubna@gmail.com]
> Gesendet: Freitag, 24. April 2009 15:37
> An: Velocity Users List
> Betreff: Re: Problem with VM and caching
>
> Yes, you should still have access to global macros.  By "seems to be
> that i don't", do you mean that you tried it, and it didn't work?  Or
> just that the docs are unclear?
>
> On Fri, Apr 24, 2009 at 6:31 AM,  <Johann.Weber@eventim.de> wrote:
>> If I set this property to true, do I have access to the global macros which were
defined in VM_global_library.vm? It seems to be that I don't. Is there a way to access the
global macros?
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Nathan Bubna [mailto:nbubna@gmail.com]
>> Gesendet: Donnerstag, 23. April 2009 20:19
>> An: Velocity Users List
>> Betreff: Re: Problem with VM and caching
>>
>> Keep your inline macros local:
>>
>> velocimacro.permissions.allow.inline.local.scope = true
>>
>> and in general, i'd recommend rereading the Velocimacro section of this:
>>
>> http://velocity.apache.org/engine/devel/developer-guide.html#Velocity_Configuration_Keys_and_Values
>>
>> On Thu, Apr 23, 2009 at 9:26 AM,  <Johann.Weber@eventim.de> wrote:
>>> Hi all,
>>>
>>>
>>>
>>> I'm using 2 vm files :
>>>
>>>
>>>
>>> The first one, located in
>>>
>>> /example1/local.vm with
>>>
>>>
>>>
>>> #macro(Hello)
>>>
>>>       Hello from example 1
>>>
>>> #end
>>>
>>>
>>>
>>> And the second one in
>>>
>>> /example2/local.vm with
>>>
>>>
>>>
>>> #macro(Hello)
>>>
>>>       Hello from example 2
>>>
>>> #end
>>>
>>>
>>>
>>> One index.htm in both directories with #Hello
>>>
>>>
>>>
>>> Now, if I try to parse the /example1/index.htm via
>>>
>>> template.merge(context, velocityWriter, </example1/local.vm >) the
>>> output is "Hello from example 1". The second call for
>>> /example2/index.htm template.merge(context, velocityWriter,
>>> </example2/local.vm >) returns "Hello from example 2". But if I'm
>>> parsing the /example1/index.htm template.merge(context, velocityWriter,
>>> </example1/local.vm >) again, I'm getting "Hello from example 2". It
>>> works correct if I turn off the loader cache.
>>>
>>> Any suggestions?
>>>
>>>
>>>
>>> Regards, Johann
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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




Mime
View raw message