Announcement Announcement Module
Collapse
No announcement yet.
Velocity and Webapp Resource Loader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Velocity and Webapp Resource Loader

    Im going through the usual hassles of setting up Velocity with Spring MVC. I'm having a problem with resource loaders. I was first loading from classpath, but this is unwieldy during development.

    I managed to get the File resource loader. The problem is that it only allows one folder for everything (at least I can't make it take more). Pluss, right now I'm using Tomcat and the Sysdeo plug-in which probably keeps my war in some expanded state. When I start using a war, I guess the paths might break.

    What I found was the Webapp Resource Loader:
    http://jakarta.apache.org/velocity/t...appLoader.html

    It's supposed to make things easy, but it won't work. It was recommended by someone on this forum, so someone must have it working.

    This is my config:
    <bean id="velocityConfigurer"
    class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
    <property name="configLocation">
    <value>classpath:velocity.properties</value>
    </property>

    </bean>

    <bean id="velocityViewResolver"
    class="org.springframework.web.servlet.view.veloci ty.VelocityViewResolver">
    <property name="prefix">
    <value></value>
    </property>
    <property name="suffix">
    <value>.vm</value>
    </property>
    <property name="exposeSpringMacroHelpers">
    <value>true</value>
    </property>
    <property name="dateToolAttribute">
    <value>dateTool</value>
    </property>
    <property name="numberToolAttribute">
    <value>numberTool</value>
    </property>
    </bean>

    And here it velocity.properties:

    resource.loader=webapp
    #webapp.loader.description=Loads resources from CLASSPATH
    webapp.resource.loader.class=org.apache.velocity.t ools.view.servlet.WebappLoader
    webapp.resource.loader.path=/WEB-INF/velocity/
    webapp.resource.loader.path=/WEB-INF/velocity/macros/

    I guess the actual file structure in my web-project is obvious from the config.

    Thanks for any help.

  • #2
    Oh, the actual error message is:

    WebappLoader : unable to retrieve ServletContext

    Comment

    Working...
    X