velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hensley, Richard" <Richard.Hens...@McKesson.com>
Subject Problem Using Anakia with velocity.properties and templatePath (v elocity-1.2-rc2)
Date Tue, 06 Nov 2001 22:45:44 GMT
I'm using Anakia to build some static web pages, and I came across a
problem when I use a velocity.properties file and a templatePath
attribute. It seems that the templatePath is not used when the
velocity.properties file is present.

The documentation says that the templatePath attribute of the Anakia
task overrides the path defined in the velocity.properties. My
velocity.properites contained only the following:

file.resource.loader.cache = true 

However when I ran ant, I got the following error: 

   [anakia] Error: 
org.apache.velocity.exception.ResourceNotFoundException: Unable to find 
resource './site.vsl' 

This sounded like a path problem so I started investigating the Anakia 
code and I found the following snippet in the Anakia.execute method: 

            if ( velocityPropertiesFile.exists() ) 
            { 
                ve.init(velocityPropertiesFile.getAbsolutePath()); 
            } 
            else if (templatePath != null && templatePath.length() > 0) 
            { 
                ve.setProperty( 
                          RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
                    templatePath); 
                ve.init(); 
            } 

If I'm reading this code correctly, it says if there is a velocity
properties file, use it. Otherwise, set the file resource loader path to
the template path.

I found this in velocity-1.2-rc2. I check the most recent
AnakiaTask.java in cvs, and it has the same code  snippet. 

I'm not sure which, but either the documentation is wrong, or the code
is wrong. 

What should the fixed? 

Would a legimate fix be to simply remove the "else"? Thus the code would
read: 

            if ( velocityPropertiesFile.exists() ) 
            { 
                ve.init(velocityPropertiesFile.getAbsolutePath()); 
            } 
            if (templatePath != null && templatePath.length() > 0) 
            { 
                ve.setProperty( 
                          RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
                    templatePath); 
                ve.init(); 
            } 

This would have init() being called twice. I'm not sure this works in
Velocity. 

Richard Hensley 
mailto:richard.hensley@mckesson.com
<mailto:richard.hensley@mckesson.com>  




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message