Results 1 to 6 of 6

Thread: why does one work and not the other?

  1. #1
    Join Date
    Oct 2004
    Posts
    27

    Default why does one work and not the other?

    Confusing issue here, any ideas most welcome!

    Why does:

    <bean id="velocityConfig"
    class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
    <property name="resourceLoaderPath"><value>/WEB-INF/velocity/</value></property>
    <property name="velocityProperties">
    <props>
    <prop key="file.resource.loader.cache">false</prop>
    <prop key="directive.foreach.counter.initial.value">0</prop>
    </props>
    </property>
    </bean>

    work correctly, but

    <bean id="velocityConfig"
    class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">

    <property name="velocityProperties">
    <props>
    <prop key="resource.loader">file</prop>
    <prop key="file.resource.loader.class">
    org.apache.velocity.runtime.resource.loader.FileRe sourceLoader
    </prop>
    <prop key="file.resource.loader.path">/WEB-INF/velocity/</prop>
    <prop key="file.resource.loader.cache">false</prop>
    <prop key="directive.foreach.counter.initial.value">0</prop>
    </props>
    </property>
    </bean>

    does not?

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    does not?
    any stackTrace, error messages...
    also, remove the cr/lf:
    Code:
    <prop key="file.resource.loader.class">org.apache.velocity.runtime.resource.loader.FileResourceLoader</prop>
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Oct 2004
    Posts
    27

    Default

    Hi!

    Thanks for the reply irbouho! Sorry its taken so long for me to respond, I didn't have a good test case, got a new job, and got sick, not necessarily in that order! But I'm back on my feet trying to figure out some Spring stuff

    OK, here is the scenario which is working:

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean">
    <property name="resourceLoaderPath"><value>/velocity/</value></property>
    <property name="velocityProperties">
    <props>
    <prop key="file.resource.loader.cache">false</prop>
    <prop key="directive.foreach.counter.initial.value">0</prop>
    </props>
    </property>
    </bean>

    However, the one below does not, and shows the error message at the bottom of the email.

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean">
    <property name="velocityProperties">
    <props>
    <prop key="resource.loader">file</prop>
    <prop key="file.resource.loader.class">org.apache.veloci ty.runtime.resource.loader.FileResourceLoader</prop>
    <prop key="file.resource.loader.path">/velocity/</prop>
    <prop key="file.resource.loader.cache">false</prop>
    <prop key="directive.foreach.counter.initial.value">0</prop>
    </props>
    </property>
    </bean>

    The only way the second one works is if I change the file.resource.loader.path to reference the first directory under the root of my project, without a leading '/'

    ie. srcHome/web/WEB-INF/velocity/

    So it will work, just not the way that I would expect, and differently in the two scenarios...can anyone explain to me why?

    Thanks!

    Mark


    PS. Error message with second config:
    ERROR - CommonsLoggingLogSystem.logVelocityMessage(42) | ResourceManager : unable to find resource 'notificationEmail.vm' in any resource loader.

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    I believe that your second example does not work because your /WEB-INF/ directory does not have a real file path that is accessible by FileResourceLoader. Are you deploying as a WAR into your container?

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  5. #5
    Join Date
    Oct 2004
    Posts
    27

    Default

    Hi Rob,

    Well, I'm just running JUnit tests actually, no deploying going on at all...

    Mark

  6. #6
    Join Date
    Oct 2004
    Posts
    27

    Default

    Hi Rob,

    I just took a look through the source and there is some logic to choose between a file resource and a SpringResourceLoader...first config is treated as a File type, and the second config is treated differently, as property entries.

    Different code, different results...

    Best,

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •