Announcement Announcement Module
Collapse
No announcement yet.
spring 3.0 Velocity integration failing to locate template. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring 3.0 Velocity integration failing to locate template.

    When i am trying to get the template for mail messages am getting following exception -

    Apr 25, 2012 7:53:53 PM org.springframework.ui.velocity.CommonsLoggingLogS ystem logVelocityMessage
    SEVERE: ResourceManager : unable to find resource 'facebook-user-published-list.vm' in any resource loader.
    org.apache.velocity.exception.ResourceNotFoundExce ption: Unable to find resource 'facebook-user-published-list.vm'
    at org.apache.velocity.runtime.resource.ResourceManag erImpl.loadResource(ResourceManagerImpl.java:483)
    at org.apache.velocity.runtime.resource.ResourceManag erImpl.getResource(ResourceManagerImpl.java:354)
    at org.apache.velocity.runtime.RuntimeInstance.getTem plate(RuntimeInstance.java:1400)
    at org.apache.velocity.app.VelocityEngine.mergeTempla te(VelocityEngine.java:370)

    I am giving my application context configuration and velocity.properties file below, let me know am doing something wrong here.

    APP CONTEXT CONF:

    Code:
    <bean id="velocityEngine"
    		class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
    	<property name="configLocation" value="/WEB-INF/conf/velocity.properties"/>
    </bean>

    velocity.properties file:

    resource.loader = file

    Code:
    file.resource.loader.description = Velocity File Resource Loader
    file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
    file.resource.loader.path = /WEB-INF/vm-templates/alert/
    #file.resource.loader.path = /WEB-INF/vm-templates/alert/, /WEB-INF/vm-templates/mail/digest/, /WEB-INF/vm-templates/mail/direct/
    file.resource.loader.cache = false
    file.resource.loader.modificationCheckInterval = 0
    As per velocity specification we can give multiple directories as well in the "file.resource.loader.path" section.

    https://velocity.apache.org/engine/r...rationexamples

  • #2
    Hi

    You can use org.springframework.ui.velocity.SpringResourceLoad er as a Velocity resource loader. It will help you load templates from WEB-INF. org.apache.velocity.runtime.resource.loader.FileRe sourceLoader loads files and tries to resolve /WEB-INF folder based on current path, which (in Tomcat) may be e.g., /var/local/tomcat/bin.

    regards
    Grzegorz Grzybek

    Comment


    • #3
      That is throwing some different autowiring exceptions. I will try to fix those ..

      If i configure like below its works fine,

      <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean">
      <property name="resourceLoaderPath" value="/WEB-INF/vm-templates/alert/"/>
      </bean>
      but i need to specify multiple dirs, that is not working that is the reason am trying the other approach..

      Comment


      • #4
        Hi

        If you look at the source of org.springframework.ui.velocity.SpringResourceLoad er.init(ExtendedProperties), you'll see this line:
        Code:
        this.resourceLoaderPaths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
        So you can use comma separated list as a value of resourceLoaderPath property.

        regards
        Grzegorz Grzybek

        Comment


        • #5
          Perfect its worked fine!

          Thanks a lot Grzegorz!

          Comment

          Working...
          X