NPE Spring Webflow与Apache Tiles 3

时间:2016-10-25 15:03:39

标签: java spring spring-webflow-2 apache-tiles

我有一个MVC和Webflow的spring项目。 我在尝试渲染指定为Web视图中视图状态视图的切片定义时获取NPE。

我的WebflowConfig:

@Configuration
public class WebFlowConfig extends AbstractFlowConfiguration {

@Autowired 
private List<ViewResolver> viewResolvers;

@Bean
public FlowExecutor flowExecutor() {
    return getFlowExecutorBuilder(flowRegistry())
            .addFlowExecutionListener(new SecurityFlowExecutionListener(), "*")
            .build();
}

@Bean
public FlowDefinitionRegistry flowRegistry() {
    return getFlowDefinitionRegistryBuilder(flowBuilderServices())
            .setBasePath("/WEB-INF/flows")
            .addFlowLocationPattern("/*.xml").build();
}

@Bean
public FlowBuilderServices flowBuilderServices() {
    return getFlowBuilderServicesBuilder()
            .setViewFactoryCreator(mvcViewFactoryCreator())
            .setDevelopmentMode(true)
            .build();
}

@Bean
public MvcViewFactoryCreator mvcViewFactoryCreator() {
    MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
    factoryCreator.setViewResolvers(viewResolvers);
    factoryCreator.setUseSpringBeanBinding(true);
    return factoryCreator;
}

@Bean
public LocalValidatorFactoryBean validator() {
    return new LocalValidatorFactoryBean();
}

我的WebMvcConfig:

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "py.com.bbva.guepardo")
@Import(WebFlowConfig.class)
public class AppConfig  extends WebMvcConfigurerAdapter { 

@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
    registry.viewResolver(viewResolver());
}

@Bean
public ViewResolver viewResolver(){
    TilesViewResolver viewResolver = new TilesViewResolver();
    viewResolver.setOrder(2);
    viewResolver.setViewClass(TilesView.class);
    return viewResolver;
}
@Bean
@Autowired
public FlowHandlerMapping flowHandlerMapping(WebFlowConfig webFlowConfig) { 
    FlowHandlerMapping handlerMapping = new FlowHandlerMapping(); 
    handlerMapping.setOrder(-1); 
    handlerMapping.setFlowRegistry(webFlowConfig.flowRegistry()); 
    return handlerMapping; 
} 

@Bean 
@Autowired
public FlowHandlerAdapter flowHandlerAdapter(WebFlowConfig webFlowConfig) { 
    FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter(); 
    handlerAdapter.setFlowExecutor(webFlowConfig.flowExecutor()); 
    handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true); 
    return handlerAdapter; 
} 

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
}

@Bean
public TilesConfigurer tilesConfigurer() {
    TilesConfigurer tilesConfigurer = new TilesConfigurer();
    tilesConfigurer.setDefinitions(new String[] { "/WEB-INF/layouts/*.xml", "/WEB-INF/views/**/views.xml" });
    tilesConfigurer.setCheckRefresh(true);
    return tilesConfigurer;
}

我尝试启动的网络流有一个指向图块定义的简单视图状态:

<view-state id="home" view="default_login" >
</view-state>

同样的定义是在@Controller类中使用@RequestMapping restful Web服务,因此mvc视图渲染有效,但它不能从Webflow定义开始工作。有什么想法吗?

控制台错误日志:

Caused by: org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'home' of flow 'home'
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:573)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:253)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    ... 69 more    
Caused by: java.lang.IllegalStateException: Exception occurred rendering view null
    at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:200)
    at org.springframework.webflow.engine.ViewState.render(ViewState.java:293)
    at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:220)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:537)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    ... 74 more
Caused by: java.lang.NullPointerException
    at org.springframework.webflow.mvc.servlet.ServletMvcView.doRender(ServletMvcView.java:55)
    at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:196)
    ... 79 more

0 个答案:

没有答案