I'm having trouble configuring a VelocityEngine instance which is shared between my parent and web application contexts.
In my parent context, I have defined "velocityEngine." This bean is used for composing emails and pulls templates from the classpath:
In the error servlet of my web app, I have defined "errorVelocityConfig" for presenting an error screen. I'd like this bean to pull templates from the WAR:Code:<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> <property name="resourceLoaderPath"> <value>classpath:com/company/app</value> </property> </bean>
When the error page is visited through the browser, the following error appears in the logs:Code:<bean id="errorVelocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath"> <value>/WEB-INF/velocity/</value> </property> <property name="velocityEngine"> <ref bean="velocityEngine" /> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="contentType"> <value>text/xml</value> </property> <property name="prefix"> <value></value> </property> <property name="suffix"> <value>.vm</value> </property> </bean>
I looks like VelocityConfigurer is not overriding the "resourceLoaderPath".Code:2005-06-09 11:37:43,018 DEBUG [org.springframework.ui.velocity.SpringResourceLoader] Looking for Velocity resource with name [error.vm] 2005-06-09 11:37:43,018 DEBUG [org.springframework.ui.velocity.SpringResourceLoader] Could not find Velocity resource: class path resource [com/company/app/error.vm] 2005-06-09 11:37:43,018 ERROR [org.apache.velocity.app.VelocityEngine] ResourceManager : unable to find resource 'error.vm' in any resource loader.
I've had this working in the past using two different VelocityEngine instances. In fact, everything works fine if the "velocityEngine" property is removed from the VelocityConfigurer. I was attempting to eliminate the duplicated VelocityEngine instances from the app when I ran into this issue.
How have others worked around this problem?
Thanks,
Patrick


Reply With Quote