我尝试使用附加组件com.vaadin.vaadin-spring.1.0.0创建Vaadin 7.5.5应用程序。这不是Spring Boot应用程序,而是可以使用Spring上下文部署的战争,它应该引导Vaadin。
错误是:
范围' vaadin-view'当前线程
无效嵌套异常是java.lang.IllegalStateException:没有活动视图
这是完整的错误跟踪:
2015-09-25 21:27:33 DEBUG DefaultListableBeanFactory:448 - Creating instance of bean 'vaadinSpringApplication'
2015-09-25 21:27:33 DEBUG InjectionMetadata:72 - Registered injected element on class [com.myapp.vaadin.demo.VaadinSpringApplication]: AutowiredFieldElement for com.vaadin.spring.navigator.SpringViewProvider com.myapp.vaadin.demo.VaadinSpringApplication.viewProvider
2015-09-25 21:27:33 DEBUG InjectionMetadata:72 - Registered injected element on class [com.myapp.vaadin.demo.VaadinSpringApplication]: AutowiredFieldElement for com.myapp.vaadin.demo.DefaultView com.myapp.vaadin.demo.VaadinSpringApplication.defaultView
2015-09-25 21:27:33 DEBUG InjectionMetadata:72 - Registered injected element on class [com.myapp.vaadin.demo.VaadinSpringApplication]: AutowiredFieldElement for com.myapp.vaadin.demo.SpringLoginView com.myapp.vaadin.demo.VaadinSpringApplication.springLoginView
2015-09-25 21:27:33 DEBUG InjectionMetadata:72 - Registered injected element on class [com.myapp.vaadin.demo.VaadinSpringApplication]: AutowiredFieldElement for com.myapp.vaadin.demo.SpringMainView com.myapp.vaadin.demo.VaadinSpringApplication.springMainView
2015-09-25 21:27:33 DEBUG InjectionMetadata:86 - Processing injected element of bean 'vaadinSpringApplication': AutowiredFieldElement for com.vaadin.spring.navigator.SpringViewProvider com.myapp.vaadin.demo.VaadinSpringApplication.viewProvider
2015-09-25 21:27:33 DEBUG DefaultListableBeanFactory:250 - Returning cached instance of singleton bean 'viewProvider'
2015-09-25 21:27:33 DEBUG AutowiredAnnotationBeanPostProcessor:490 - Autowiring by type from bean name 'vaadinSpringApplication' to bean named 'viewProvider'
2015-09-25 21:27:33 DEBUG InjectionMetadata:86 - Processing injected element of bean 'vaadinSpringApplication': AutowiredFieldElement for com.myapp.vaadin.demo.DefaultView com.myapp.vaadin.demo.VaadinSpringApplication.defaultView
2015-09-25 21:27:33 DEBUG DefaultListableBeanFactory:448 - Creating instance of bean 'viewCache'
2015-09-25 21:27:33 DEBUG DefaultListableBeanFactory:250 - Returning cached instance of singleton bean 'com.vaadin.spring.VaadinConfiguration'
2015-09-25 21:27:33 DEBUG CommonAnnotationBeanPostProcessor:216 - Found destroy method on class [com.vaadin.spring.internal.DefaultViewCache]: void com.vaadin.spring.internal.DefaultViewCache.destroy()
2015-09-25 21:27:33 DEBUG CommonAnnotationBeanPostProcessor:288 - Registered destroy method on class [com.vaadin.spring.internal.DefaultViewCache]: org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement@5cd39ffa
2015-09-25 21:27:33 DEBUG DefaultListableBeanFactory:484 - Finished creating instance of bean 'viewCache'
Sep 25, 2015 9:27:33 PM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaadinSpringApplication': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.myapp.vaadin.demo.DefaultView com.myapp.vaadin.demo.VaadinSpringApplication.defaultView; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultView': Scope 'vaadin-view' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No active view
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:344)
at com.vaadin.spring.internal.BeanStore.create(BeanStore.java:71)
at com.vaadin.spring.internal.UIScopeImpl$UIBeanStore.create(UIScopeImpl.java:279)
at com.vaadin.spring.internal.BeanStore.get(BeanStore.java:62)
at com.vaadin.spring.internal.SessionLockingBeanStore.get(SessionLockingBeanStore.java:46)
at com.vaadin.spring.internal.UIScopeImpl.get(UIScopeImpl.java:81)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:339)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:219)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:351)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:332)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1057)
at com.vaadin.spring.server.SpringUIProvider.createInstance(SpringUIProvider.java:172)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:191)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:351)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
这是应用程序主类:
@Theme("valo")
@SpringUI
public class VaadinSpringApplication extends UI {
@Configuration
@EnableVaadin
public static class VaadinSpringApplicationConfiguration {}
@Autowired
SpringViewProvider viewProvider;
@Override
protected void init(VaadinRequest request) {
Navigator navigator = new Navigator(this, this);
navigator.addProvider(viewProvider);
navigator.navigateTo(DefaultView.NAME);
}
}
DefaultView.java
@SpringComponent
@SpringView(name = DefaultView.NAME)
public class DefaultView extends CustomComponent implements View {
public static final String NAME = "defaultView";
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
Button button = new Button("Click Me");
setCompositionRoot(layout);
}
}
正如您在日志中看到的那样,已经创建了spring bean(viewCache,defaultView,springLoginView,springMainView)。但是,一旦我试图将它注入主要课程 - 得到错误" 范围' vaadin-view'当前线程无法激活"。
请指教。谢谢。