You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tom Bednarz <li...@bednarz.ch> on 2002/04/11 09:03:06 UTC

Where to place VM_global_library.vm

Hi,

I have put some macros in the VM_global_library.vm file. Unfortunately they
are NOT known and I assume that the file is not found. My
velocity.properties file looks as follows:

--------- begin -------
file.resource.loader.path = Templates
file.resource.loader.cache = false;

runtime.log = /WEB-INF/logs/velocity.log

velocimacro.library.autoreload = true
--------- end -----------------

I have a directory Templates with several sub-directories all containing
lots of vm files. I put VM_global_library directly in the Templates
directory but the macros do not work.

They work when I declare them inline (at the beginning of the file I am
using it).


Beside the above configuration I also tried the following:


--------------- begin -------------
velocimacro.library = /WEB-INF/VM_global_library.vm

velocimacro.permissions.allow.inline = true
velocimacro.permissions.allow.inline.to.replace.global = false
velocimacro.permissions.allow.inline.local.scope = false

velocimacro.context.localscope = false
------------------- end -------------------

I then put the VM_global_library.vm file into the /WEB-INF directory.
Unfortunately this does NOT work either.

What am I missing?

Thomas


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Where to place VM_global_library.vm

Posted by Gabriel Sidler <si...@teamup.ch>.
Tom,
I assume your question is related to the VelocityViewServlet that
comes with the Struts tools. If not, my answer below does not apply.


Tom Bednarz wrote:

> Hi,
> 
> I have put some macros in the VM_global_library.vm file. Unfortunately they
> are NOT known and I assume that the file is not found. My
> velocity.properties file looks as follows:
> 
> --------- begin -------
> file.resource.loader.path = Templates
> file.resource.loader.cache = false;
> 
> runtime.log = /WEB-INF/logs/velocity.log
> 
> velocimacro.library.autoreload = true
> --------- end -----------------


VelocityViewServlet does not use the file resource loader. It comes
with its own resource loader (WebappLoader), specifically tailored
to working with servlet applications. Furthermore, log messages
are directed to the log facilities of the servlet container. Therefore,
the first three lines of above snippet have no effect.

An example Velocity configuration file is included with the Struts
example application. See directory
jakarta-velocity-tools/struts/examples/struts/WEB-INF/velocity.properties
It should work as is.

...

> 
> 
> Beside the above configuration I also tried the following:
> 
> 
> --------------- begin -------------
> velocimacro.library = /WEB-INF/VM_global_library.vm
> 
> velocimacro.permissions.allow.inline = true
> velocimacro.permissions.allow.inline.to.replace.global = false
> velocimacro.permissions.allow.inline.local.scope = false
> 
> velocimacro.context.localscope = false
> ------------------- end -------------------
> 
> I then put the VM_global_library.vm file into the /WEB-INF directory.
> Unfortunately this does NOT work either.


I use this same configuration and it works fine. Check out the error
log of your servlet container. VelocityViewServlet does extensive
logging on startup. Look for the following lines in the log related to the
loading of the global macros.

[2002/04/04 15:01:30]  Velocity   [info] Velocimacro : initialization starting.
[2002/04/04 15:01:30]  Velocity   [info] Velocimacro : adding VMs from VM library template : /WEB-INF/VM_global_library.vm
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : added new VM : #errorMarkup( ) : source = /WEB-INF/VM_global_library.vm
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : added new VM : #errorMarkupForProperty( property ) : source = /WEB-INF/VM_global_library.vm
[2002/04/04 15:01:31]  Velocity   [info] ResourceManager : found /WEB-INF/VM_global_library.vm with loader org.apache.velocity.tools.view.servlet.WebappLoader
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro :  VM library template macro registration complete.
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : allowInline = true : VMs can be defined inline in templates
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : allowInlineLocal = false : VMs defined inline will be  global in scope if allowed.
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : messages on  : VM system will output logging messages
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : autoload off  : VM system will not automatically reload global library macros
[2002/04/04 15:01:31]  Velocity   [info] Velocimacro : initialization complete.
[2002/04/04 15:01:31]  Velocity   [info] Velocity successfully started.


What do you find?


Gabe




> 
> What am I missing?
> 
> Thomas
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> .
> 
> 


-- 
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>