FAQ
[ http://issues.apache.org/jira/browse/VELOCITY-274?page=all ]

Will Glass-Husain updated VELOCITY-274:
---------------------------------------

Bugzilla Id: (was: 29766)
Fix Version: 1.5
Description:
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!

was:
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!

Environment:
Operating System: All
Platform: All

was:
Operating System: All
Platform: All

Assign To: (was: Velocity-Dev List)

I agree. Anyone want to create an easy patch to trim spaces from Velocity Properties? ideally this should apply to any property which loads a class name.
Errant space in velocity.properties file can cause classpath resource loader to fail
------------------------------------------------------------------------------------

Key: VELOCITY-274
URL: http://issues.apache.org/jira/browse/VELOCITY-274
Project: Velocity
Type: Bug
Components: Source
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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira


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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriesvelocity
postedSep 18, '05 at 10:10p
activeSep 18, '05 at 10:10p
posts1
users1
websitevelocity.apache.org

1 user in discussion

Will Glass-Husain (JIRA): 1 post

People

Translate

site design / logo © 2021 Grokbase