Announcement Announcement Module
Collapse
No announcement yet.
velocity and URLResourceLoader trouble Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • velocity and URLResourceLoader trouble

    how do i load velocity templates over http via the URLResourceLoader ?. i can successfully load using the FileResourceLoader with this velocityConfig in my springapp-servlet.xml

    <bean id="velocityConfig" class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
    <property name="resourceLoaderPath">
    <value>/WEB-INF/velocity_old/</value>
    </property>
    <property name="velocityProperties">
    <props><prop key="velocimacro.library">VM_global_library.vm</prop> </props>
    </property>
    </bean>

    it seems like there must be an easy way to change to point to a url instead. have tried changing to variants of this path:
    <property name="resourceLoaderPath">
    <value>http: //localhost:8080/content/vm_templates/</value>
    </property>

    but then tomcat does not start and can find nothing of use in logs.

    using:
    tomcat 5.5
    velocity-1.5.jar
    velocity-tools-view-1.4.jar

    thanks

  • #2
    solution

    i'll post this for posterity sake. the problem was that for this dev environment both sites were running on tomcat. when tomcat was starting spring was trying to cache the VM_global_library.vm file and bombed because it couldn't load it from itself yet. what clued me in was when i stopped tomcat it threw a java socket error - because it couldn't open the socket to load the template.

    the whole point of using urlresourceloader would be to load from a different server or box so i imagine this problem would not be likely to happen in a more life-like environment.

    here's the final config that worked:

    Code:
    <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
            <property name="velocityProperties">
              <props>
                <prop key="resource.loader">MYO</prop>
    	    
                <prop key="MYO.resource.loader.class">org.apache.velocity.runtime.resource.loader.URLResourceLoader</prop>
                <prop key="MYO.resource.loader.root">http: //foobar/content/vm_templates/</prop>
                <prop key="MYO.resource.loader.cache">false</prop>
                <prop key="MYO.resource.loader.modificationCheckInterval">0</prop>
                <prop key="velocimacro.library">VM_global_library.vm</prop>
                </props>
             </property>
        </bean>

    Comment

    Working...
    X