velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: VelocityEngine...
Date Thu, 04 Dec 2008 22:37:23 GMT
On Thu, Dec 4, 2008 at 2:27 PM, carlo latasa <clatasa@gmail.com> wrote:
> Ok - re-read the Velocity docs and am finding that I have to use absolute
> paths for file.resource.loader.path in the velocity.properties. If the path
> is just "." or "WEB-INF" is it relative to the jar location or ?

if the path is not absolute, it is relative to the directory the JVM
was started up in.  this is obviously not very web-application
friendly.

for a web application, it is strongly recommended that you use the
ClasspathResourceLoader or the WebappResourceLoader, the latter being
part of VelocityTools and probably your best choice.  Just add the
VelocityTools 2.0-beta3 jar to your lib and change your properties to:

resource.loader = webapp
webapp.resource.loader.class =
org.apache.velocity.tools.view.WebappResourceLoader
webapp.resource.loader.path = /WEB-INF/

> Either way, I'm still getting ResourceNotFoundException  when trying to find
> my vm (when I know its there and it's permissions allow for reading). Could
> it be an encoding issue?
>
> Here's what my velocity.log sayz:
>
> 2008-12-04 14:16:03,795 - Trying to use logger class
> org.apache.velocity.runtime.log.Log4JLogChute
> 2008-12-04 14:16:03,795 - Using logger class
> org.apache.velocity.runtime.log.Log4JLogChute
> 2008-12-04 14:16:03,795 - Default ResourceManager initializing. (class
> org.apache.velocity.runtime.resource.ResourceManagerImpl)
> 2008-12-04 14:16:03,796 - ResourceLoader instantiated:
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> 2008-12-04 14:16:03,796 - FileResourceLoader : initialization starting.
> 2008-12-04 14:16:03,796 - Do unicode file recognition:  false
> 2008-12-04 14:16:03,796 - FileResourceLoader : adding path
> '/Users/carlo/ccs/denali/webapp'
> 2008-12-04 14:16:03,796 - FileResourceLoader : initialization complete.
> 2008-12-04 14:16:03,796 - ResourceCache: initialized (class
> org.apache.velocity.runtime.resource.ResourceCacheImpl)
> 2008-12-04 14:16:03,797 - Default ResourceManager initialization complete.
> 2008-12-04 14:16:03,797 - Loaded System Directive:
> org.apache.velocity.runtime.directive.Literal
> 2008-12-04 14:16:03,797 - Loaded System Directive:
> org.apache.velocity.runtime.directive.Macro
> 2008-12-04 14:16:03,798 - Loaded System Directive:
> org.apache.velocity.runtime.directive.Parse
> 2008-12-04 14:16:03,798 - Loaded System Directive:
> org.apache.velocity.runtime.directive.Include
> 2008-12-04 14:16:03,798 - Loaded System Directive:
> org.apache.velocity.runtime.directive.Foreach
> 2008-12-04 14:16:03,807 - Created '20' parsers.
> 2008-12-04 14:16:03,808 - Velocimacro : initialization starting.
> 2008-12-04 14:16:03,809 - Velocimacro : "velocimacro.library" is not set.
> Trying default library: VM_global_library.vm
> 2008-12-04 14:16:03,817 - Velocimacro : Default library not found.
> 2008-12-04 14:16:03,818 - Velocimacro : allowInline = true : VMs can be
> defined inline in templates
> 2008-12-04 14:16:03,818 - Velocimacro : allowInlineToOverride = false : VMs
> defined inline may NOT replace previous VM definitions
> 2008-12-04 14:16:03,818 - Velocimacro : allowInlineLocal = false : VMs
> defined inline will be global in scope if allowed.
> 2008-12-04 14:16:03,818 - Velocimacro : autoload off : VM system will not
> automatically reload global library macros
> 2008-12-04 14:16:03,818 - Velocimacro : Velocimacro : initialization
> complete.
> 2008-12-04 14:16:03,818 - RuntimeInstance successfully initialized.
> 2008-12-04 14:16:32,477 - ResourceManager : unable to find resource
> '/Users/carlo/ccs/denali/webapp/template/dashheader.vm' in any resource
> loader.
>
> Ouch.
>
> On Thu, Dec 4, 2008 at 12:20 PM, carlo latasa <clatasa@gmail.com> wrote:
>
>> Thanks both of you for the quick response.
>>
>> So I'm now creating a static instance of the VelocityEngine in my Directive
>> base class and calling init in a static initalizer.
>>
>> Now when getTemplate is called on the velocityEngine instance I get:
>>
>> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
>> resource '/templates/dashheader.vm'
>>     at
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)
>>     at
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
>>     at
>> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)...
>>
>> There's a setting in either velocity.properties or struts.properties that
>> tells the engine where to look. What is that setting?
>>
>> I'm assuming that calling init() on the engine with no params will default
>> to using the velocity.properties file in my WEB-INF/classes dir.
>>
>> Thanks again.
>>
>>
>>
>
>
> --
> Carlo Latasa
> EdgeDriven.com
> Cell: (415) 385-1567
>

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


Mime
View raw message