Announcement Announcement Module
Collapse
No announcement yet.
Velocity + CookieTool + Spring = NPE? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Velocity + CookieTool + Spring = NPE?

    Attempting to use VelocityTools 2.0 CookieTool, but seeing a NPE when used with Spring MVC 3.0:

    2010-01-11 09:25:12.093::WARN: /
    java.lang.NullPointerException
    at org.apache.velocity.tools.view.CookieTool.add(Cook ieTool.java:169)
    at org.apache.velocity.tools.view.CookieTool.add(Cook ieTool.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.velocity.util.introspection.UberspectIm pl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
    at org.apache.velocity.util.introspection.UberspectIm pl$VelMethodImpl.invoke(UberspectImpl.java:378)
    at org.apache.velocity.runtime.parser.node.ASTMethod. execute(ASTMethod.java:270)
    at org.apache.velocity.runtime.parser.node.ASTReferen ce.execute(ASTReference.java:252)
    at org.apache.velocity.runtime.parser.node.ASTReferen ce.render(ASTReference.java:332)
    at org.apache.velocity.runtime.parser.node.SimpleNode .render(SimpleNode.java:336)
    at org.apache.velocity.Template.merge(Template.java:3 28)
    at org.apache.velocity.Template.merge(Template.java:2 35)
    at org.springframework.web.servlet.view.velocity.Velo cityView.mergeTemplate(VelocityView.java:517)
    at org.springframework.web.servlet.view.velocity.Velo cityView.doRender(VelocityView.java:462)
    at org.springframework.web.servlet.view.velocity.Velo cityView.renderMergedTemplateModel(VelocityView.ja va:291)


    Beans:

    Code:
        <bean id="velocityConfig"
              class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
            <property name="resourceLoaderPath" value="/" />
            <property name="velocityProperties">
                <map>
                    <entry key="UseCache" value="false" />
                    <entry key="file.resource.loader.modificationCheckInterval" value="1" />
                    <entry key="file.resource.loader.cache" value="false" />
                    <entry key="velocimacro.library.autoreload" value="true" />
                    <entry key="velocimacro.permissions.allow.inline.to.replace.global" value="true" />
                </map>
            </property>
        </bean>
    
        <bean id="viewResolver"
              class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
            <property name="cache" value="true" />
            <property name="contentType" value="text/html; charset=UTF-8" />
            <property name="exposeSpringMacroHelpers" value="true" />
            <property name="prefix" value="" />
            <property name="suffix" value="" />
            <property name="toolboxConfigLocation" value="/WEB-INF/fec/toolbox.xml" />
        </bean>
    toolbox.xml:

    Code:
    <?xml version="1.0"?>
    <toolbox>
         <!-- http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/view/CookieTool.html -->
    <tool>
     <key>cookie</key>
     <scope>request</scope>
     <class>org.apache.velocity.tools.view.CookieTool</class>
    </tool>


    Any ideas? Using Velocity version 1.6.2
Working...
X