Back Forum Reply New

spring-2.5.2 and velocity-tools-1.4

Hello.
I upgraded from spring-1.2.9 to spring-2.5.2 and everything seems to be working fine except for the loading of my velocity templates.  I upgraded velocity-tools from 1.2 to 1.4 because the Spring Javadocs say 1.3 or greater as there were some small changes to velocity-tools after 1.2.

This is in my applicationContext.xml and has not changed:Code:   lt;bean id=quot;velocityConfigurerquot; class=quot;org..web.servlet.view.velocity.VelocityConfigurerquot;gt;       lt;property name=quot;resourceLoaderPathquot; value=quot;quot;/gt;       lt;property name=quot;velocityPropertiesquot;gt;lt;propsgt;    lt;prop key=quot;velocimacro.libraryquot;gt;/includes/macros.vmlt;/propgt;    lt;prop key=quot;velocimacro.library.autoreloadquot;gt;truelt;/propgt;    lt;prop key=quot;velocimacro.permissions.allow.inlinequot;gt;truelt;/propgt;    lt;prop key=quot;velocimacro.permissions.allow.inline.to.replace.globalquot;gt;falselt;/propgt;    lt;prop key=quot;velocimacro.permissions.allow.inline.local.scopequot;gt;falselt;/propgt;    lt;prop key=quot;velocimacro.context.localscopequot;gt;falselt;/propgt;    lt;prop key=quot;tools.view.servlet.error.templatequot;gt;/layouts/layout_error.vmlt;/propgt;    lt;prop key=quot;tools.view.servlet.layout.directoryquot;gt;/layouts/lt;/propgt;    lt;prop key=quot;tools.view.servlet.layout.default.templatequot;gt;default_layout.vmlt;/propgt;lt;/propsgt;       lt;/propertygt;   lt;/beangt;
And I now get this in my logs:

Code:
ERROR [2008-04-14 13:24:47,322] (CommonsLoggingLogSystem.java:43) - ResourceManager : unable to find resource '/includes/macros.vm' in any resource loader.
ERROR [2008-04-14 13:24:47,323] (CommonsLoggingLogSystem.java:43) - Velocimacro : Velocimacro : Error using VM library : /includes/macros.vm
ERROR [2008-04-14 13:24:47,325] (CommonsLoggingLogSystem.java:43) - org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource '/includes/macros.vm'       at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)       at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)       at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)       at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1077)       at org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(VelocimacroFactory.java:196)       at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:251)       at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:116)       at org..ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:256)       at org..web.servlet.view.velocity.VelocityConfigurer.afterPropertiesSet(VelocityConfigurer.java:110)       at org..beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1333)       at org..beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1299)       at org..beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)       at org..beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)       at java.security.AccessController.doPrivileged(Native Method)       at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)       at org..beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)       at org..beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)       at org..beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)       at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)       at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)       at org..beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:430)       at org..context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)       at org..context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)       at org..web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:254)       at org..web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:198)       at org..web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)       at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)       at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)       at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)       at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)       at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)       at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)       at org.apache.catalina.core.StandardService.start(StandardService.java:450)       at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)       at org.apache.catalina.startup.Catalina.start(Catalina.java:551)       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)       at java.lang.reflect.Method.invoke(Method.java:585)       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Is there something I need to change?  Is there something I am doing wrong?  Has anyone else encountered this when upgrading?

Thanks a lot.Charlie

Charlie,

I think that it is just an issue of the order things are loaded.  I get that message and everything works just fine.  So, unless you are having issues with Velocity, I would not worry about it.

Steve O

Steve O,
I am actually having problems.  I can't view any pages.    When I go to /index.htm it should resolve /index.vm but it doesn't.  I get basically the same error but with the new page that it does not find.

I thought about it a bit and figured out what is quot;wrongquot; but I don't know how to fix it.

In spring-1.2.x if I left quot;resourceLoaderPathquot; empty, Spring searched for templates at the root of the webapp.  Now, Spring seems to be searching for templates in my classpath instead.  So, if I put my templates in quot;/WEB-INF/classes/quot; than they will be found.  But if they are in quot;/quot; than they will not be found.  I am going to keep looking at the code to see if there is some setting I can change or if there is something I can override.

If you have any ideas let me know.  Oh, and where do you keep your templates?Charlie

Holy crap.  I can't believe this just happened:Code:   lt;bean id=quot;velocityConfigurerquot; class=quot;org..web.servlet.view.velocity.VelocityConfigurerquot;gt;       lt;property name=quot;resourceLoaderPathquot; value=quot;quot;/gt;   lt;/beangt;
Has to be:

Code:   lt;bean id=quot;velocityConfigurerquot; class=quot;org..web.servlet.view.velocity.VelocityConfigurerquot;gt;       lt;property name=quot;resourceLoaderPathquot; value=quot;/quot;/gt;   lt;/beangt;
The quot;/quot; made the difference.  I guess if you leave it empty it looks in the classpath.  Ridiculous.  

Well, thanks for the help.Charlie
¥
Back Forum Reply New