I've spent more than three hours to figure out what is the problem, but I couldn't find it.
I've learned how to use SpringMVC and made a sample web application.
However, when I tried to integrate the web flow concept to the original spring mvc(which means, add webflow configuration to the dispacher context), I got this problem.
Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webflowContextConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.webflow.executor.FlowExecutor edu.sscrg.wmfs.web.config.WebflowContextConfiguration.flowExecutor;
My WebModelFactoryServiceInitializer.java, which is dispacher initializer is
Code:public class WebModelFactoryServiceInitializer implements WebApplicationInitializer { private static final String DISPATCHER_SERVLET_NAME = "dispatcher"; public void onStartup(ServletContext servletContext) throws ServletException { registerDispatcherServlet(servletContext); } private void registerDispatcherServlet(ServletContext servletContext) { AnnotationConfigWebApplicationContext dispacherContext = createContext(WebMvcContextConfiguration.class, WebflowContextConfiguration.class); ServletRegistration.Dynamic dispatcher; dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(dispacherContext)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); } private AnnotationConfigWebApplicationContext createContext(final Class<?>... annotatedClasses) { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.register(annotatedClasses); return context; } }
My WebflowContextConfiguration is
Code:@Configuration @ImportResource("classpath:/webflow_config/webflow-config.xml") public class WebflowContextConfiguration { @Autowired private FlowExecutor flowExecutor; @Autowired private FlowDefinitionRegistry flowRegistry; @Autowired private LocaleChangeInterceptor localeChangeInterceptor; @Bean public FlowHandlerAdapter flowHandlerAdapter() { FlowHandlerAdapter flowHandlerAdapter = new FlowHandlerAdapter(); flowHandlerAdapter.setFlowExecutor(flowExecutor); return flowHandlerAdapter; } @Bean public FlowHandlerMapping flowHandlerMapping() { FlowHandlerMapping flowHandlerMapping = new FlowHandlerMapping(); flowHandlerMapping.setInterceptors(new Object[] { localeChangeInterceptor }); flowHandlerMapping.setFlowRegistry(flowRegistry); return flowHandlerMapping; } }
My webflow-config.xml is
Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"> <webflow:flow-executor id="flowExecutor"/> <webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/view" flow-builder-services="flowBuilderServices"> <webflow:flow-location-pattern value="/**/*-flow.xml" /> </webflow:flow-registry> <webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" conversion-service="conversionService" validator="validator" development="true" /> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> <property name="viewResolvers"> <list> <ref bean="tilesViewResolver"/> <ref bean="viewResolver"/> </list> </property> </bean> <bean id="conversionService" class="org.springframework.binding.convert.service.DefaultConversionService"> <constructor-arg ref="mvcConversionService"/> </bean> </beans>
Should there be more code or configuration to autowire the flowExecutor and flowRegistry in the WebflowContextConfiguration.java configuration?
I tried to modify the sample code from Pro SpringMVC: with Web Flow (http://www.apress.com/9781430241553): chapter 11 sample code(I attached the sample code, it is built with gradle). The sample code works well with the same code, but mine doesn't work. I want to know what I have to do more to make that part work.
Help me~!!
Thanks.



Reply With Quote