Announcement Announcement Module
Collapse
No announcement yet.
How do I use velocity support Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I use velocity support

    I am trying to use velocity support in spring in a standalone app. I have defined the velocity engine bean using
    Code:
    	<bean id="velocity2" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
        	<property name="velocityProperties">
            	<props>
                	<prop key="resource.loader">file</prop>
                	<prop key="file.resource.loader.class">org.apache.velocity.runtime.resource.loader.FileResourceLoader</prop>
                 	<prop key="file.resource.loader.path">/var/www/</prop>
            	</props>
        	</property>
    	</bean>
    When I try using it with a template at /var/www/website/index.html I get the following exception

    Code:
    Caused by&#58; org.apache.velocity.exception.ResourceNotFoundException&#58; Unable to find resource '/var/www/website/index.html'
    	at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource&#40;ResourceManagerImpl.java&#58;458&#41;
    	at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource&#40;ResourceManagerImpl.java&#58;341&#41;
    	at org.apache.velocity.runtime.RuntimeInstance.getTemplate&#40;RuntimeInstance.java&#58;831&#41;
    	at org.apache.velocity.app.VelocityEngine.mergeTemplate&#40;VelocityEngine.java&#58;440&#41;
    	at org.apache.velocity.app.VelocityEngine.mergeTemplate&#40;VelocityEngine.java&#58;419&#41;
    	at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplate&#40;VelocityEngineUtils.java&#58;55&#41;
    	at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString&#40;VelocityEngineUtils.java&#58;117&#41;
    Am I using it correctly?

    thank you

  • #2
    Caused by: org.apache.velocity.exception.ResourceNotFoundExce ption: Unable to find resource '/var/www/website/index.html'
    did you check index.html exists in the file system and you have permissions to access it. Also, can you show the code you use to process this template?

    Comment


    • #3
      Ok, I got it to work. Basically for anyone else who has trouble with this the file.resource.loader.path must be set to empty for velocity to use absolute file names. So you actually need the line

      <prop key="file.resource.loader.path"></prop>

      Hope this helps someone

      Comment

      Working...
      X