You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Henning Schmiedehausen (JIRA)" <de...@velocity.apache.org> on 2007/03/08 01:04:38 UTC

[jira] Closed: (VELOCITY-274) Errant space in velocity.properties file can cause classpath resource loader to fail

     [ https://issues.apache.org/jira/browse/VELOCITY-274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henning Schmiedehausen closed VELOCITY-274.
-------------------------------------------


> Errant space in velocity.properties file can cause classpath resource loader to fail
> ------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-274
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-274
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.4
>         Environment: Operating System: All
> Platform: All
>            Reporter: Kris Nuttycombe
>             Fix For: 1.5
>
>
> I just spent about two hours ferreting out this obnoxious bug, but it should be
> trivial to fix.
> When configuring my velocity.properties file, I had the lines (taken verbatim
> from the documentation):
> # specify the resource loaders to use
> resource.loader = class 
> class.resource.loader.description = Velocity Classpath Resource Loader
> class.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> class.resource.loader.cache = false
> I was consistently able to load a resource file from the classpath with
> getClass().getClassLoader().getResourceAsStream("/my/package/foo.vm") but
> Velocity consistently failed with the following stack trace:
> Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable to
> find resource '/gov/noaa/nndc/idb/render/vm/field/textField.vm'
>     at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:458)
>     at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:341)
>     at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:831)
>     at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:813)
>     at
> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:285)
>     at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:469)
>     at gov.noaa.nndc.idb.IdbInitServlet.initVelocity(IdbInitServlet.java:241)
>     ... 47 more
> After much ado and hacking around, here is some of my debugging code and the output:
> System.out.println("Resource Loaders: " +
> Velocity.getProperty(RuntimeConstants.RESOURCE_LOADER));
> System.out.println("Loader class: " +
> Velocity.getProperty("class.resource.loader.class"));            
> Resource Loaders: [class ]
> Loader class: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> It turns out that that there was an errant space in the properties file after
> the word "class" and this was causing the classpath resource loader not to be
> found. Velocity should trim this whitespace when reading the properties file!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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