Announcement Announcement Module
Collapse
No announcement yet.
NullPointerException on ServletMvcView.java:50 - Tiles view for SWF flow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NullPointerException on ServletMvcView.java:50 - Tiles view for SWF flow

    I am following the booking-mvc example to integrate Tile with SWF. Tiles is working for simple JSP pages (mapped to .do), but when I try to access a page connected to a flow I get the following NullPointerException. I could use help in determining what's (presumably) missing from my configuration.

    Code:
    java.lang.NullPointerException
    	org.springframework.webflow.mvc.servlet.ServletMvcView.doRender(ServletMvcView.java:50)
    	org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:187)
    	org.springframework.webflow.engine.ViewState.render(ViewState.java:296)
    	org.springframework.webflow.engine.ViewState.refresh(ViewState.java:243)
    	org.springframework.webflow.engine.ViewState.resume(ViewState.java:221)
    	org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
    	org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    	org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
    	org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    Here's the relevant configuration. Please let me know if you need more to determine the cause.

    login.xml (my flow):

    Code:
    <on-start>
            <evaluate expression="loginService.start(flowRequestContext)"/>
        </on-start>
    
        <!-- By default, the first state is the start state. -->
        <view-state id="login" view="account/login/loginForm" model="login">
            <on-entry>
                <evaluate expression="loginService.entry(flowRequestContext)"/>
            </on-entry>
            <on-render>
                <render fragments="body"/>
            </on-render>
            <transition on="submit" to="success" validate="true">
                <evaluate expression="loginService.submit(flowRequestContext, login)"/>
            </transition>
            <transition on="cancel" to="cancel" validate="false">
                <evaluate expression="loginService.cancel(flowRequestContext, login)"/>
            </transition>
            <on-exit>
                <evaluate expression="loginService.exit(flowRequestContext)"/>
            </on-exit>
        </view-state>
    
        <end-state id="success" view="externalRedirect:contextRelative:/home.do?success=true"/>
        <end-state id="cancel" view="externalRedirect:contextRelative:/home.do?cancel=true"/>
    
        <on-end>
            <evaluate expression="loginService.end(flowRequestContext)"/>
        </on-end>
    loginForm.jsp (just a simple heading tag, to start):

    Code:
    <h1>Login</h1>
    views.xml:

    Code:
    <tiles-definitions>
        <definition name="loginForm" template="/WEB-INF/standard.jsp">
            <put-attribute name="body" value="/WEB-INF/account/login/loginForm.jsp"/>
        </definition>
    </tiles-definitions>
    standard.jsp ((just a simple insert, to start):

    Code:
    <tiles:insertAttribute name="body"/>
    servlet.xml (mvc, swf, etc):

    Code:
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <value>
                    /account/signup/signup.do=flowController
                    /account/login/login.do=flowController
                </value>
            </property>
            <property name="alwaysUseFullPath" value="true"/>
        </bean>
    
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
    
    <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
    
    <bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
        </bean>
    
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
            <property name="definitions" value="/WEB-INF/**/views.xml"/>
        </bean>
    
    <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
            <property name="flowExecutor" ref="flowExecutor"/>
        </bean>
    
    <flow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>
    
    <flow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
            <!-- NOTE: flow filenames must match flow name (e.g. flow = login, filename = login.xml) -->
            <flow:flow-location-pattern value="/WEB-INF/**/*.xml"/>
        </flow:flow-registry>
    
    <flow:flow-builder-services
                id="flowBuilderServices"
                view-factory-creator="viewFactoryCreator"
                validator="validator"/>
    
    <bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
            <property name="viewResolvers" ref="tilesViewResolver"/>
            <property name="useSpringBeanBinding" value="true"/>
        </bean>
    
    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>

  • #2
    I've figured out that my problem was in naming my Tiles definition. The definition name must match path to the filename, or, perhaps its the view name (in my case, they are the same). Here's what views.xml should look like. Notice, the path in name matches the filename and view name references in login.xml.

    views.xml:

    Code:
    <tiles-definitions>
        <definition name="loginForm" template="/WEB-INF/standard.jsp">
            <put-attribute name="body" value="/WEB-INF/account/login/loginForm.jsp"/>
        </definition>
    </tiles-definitions>

    Comment

    Working...
    X