我将Vaadin 8.7.1与Vaadin / Spring Boot 3.1.1集成在一起使用。该Web应用程序部署在Ubuntu Linux服务器上的Apache Tomcat 8服务器(未嵌入式)中。
我只是无法找到以下错误的解决方法,它似乎与会话过期有关,但我找不到根本原因。
我的Vaadin UI类使用以下注释定义如下:
@Theme("gdc")
@SpringUI
@SpringViewDisplay
@EnableVaadinNavigation
@StyleSheet({ "http://fonts.googleapis.com/css?family=Droid+Sans" })
public class GdCWebUI extends UI implements ViewDisplay {
// some UI code here
}
我通过Spring侦听器按以下方式处理会话管理:
@Component
public class GdCSessionListener implements HttpSessionListener {
@Override
public void sessionCreated(final HttpSessionEvent event) {
event.getSession().setMaxInactiveInterval((int) TimeUnit.HOURS.toSeconds(2));
}
@Override
public void sessionDestroyed(final HttpSessionEvent event) {
Optional.ofNullable(VaadinSession.getCurrent())
.ifPresent(VaadinSession::close);
Optional.ofNullable(VaadinService.getCurrentRequest())
.map(VaadinRequest::getWrappedSession)
.ifPresent(WrappedSession::invalidate);
}
}
会话超时也在Tomcat conf / web中定义如下:
<session-config>
<session-timeout>120</session-timeout>
</session-config>
堆栈跟踪在这里:
2019-03-14 09:12:20.143 ERROR 35944 --- [-nio2-80-exec-3] o.a.c.c.C.[.[.[/].[gdCServlet] : Servlet.service() for servlet [gdCServlet] in context with path [] threw exception [com.vaadin.server.ServiceException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gdCWebUI': Scope 'vaadin-ui' 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: Current VaadinSession is not open] with root cause
java.lang.IllegalStateException: Current VaadinSession is not open
at com.vaadin.spring.internal.UIScopeImpl$VaadinSessionBeanStoreRetrievalStrategy.getVaadinSession(UIScopeImpl.java:148) ~[vaadin-spring-3.1.1.jar:3.1.1]
at com.vaadin.spring.internal.UIScopeImpl$VaadinSessionBeanStoreRetrievalStrategy.getUIStore(UIScopeImpl.java:155) ~[vaadin-spring-3.1.1.jar:3.1.1]
at com.vaadin.spring.internal.UIScopeImpl$VaadinSessionBeanStoreRetrievalStrategy.getBeanStore(UIScopeImpl.java:184) ~[vaadin-spring-3.1.1.jar:3.1.1]
at com.vaadin.spring.internal.UIScopeImpl.getBeanStore(UIScopeImpl.java:103) ~[vaadin-spring-3.1.1.jar:3.1.1]
at com.vaadin.spring.internal.UIScopeImpl.get(UIScopeImpl.java:79) ~[vaadin-spring-3.1.1.jar:3.1.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:346) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:220) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1016) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:344) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:339) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1092) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at com.vaadin.spring.server.SpringUIProvider.createInstance(SpringUIProvider.java:241) ~[vaadin-spring-3.1.1.jar:3.1.1]
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:193) ~[vaadin-server-8.7.1.jar:8.7.1]
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:76) ~[vaadin-server-8.7.1.jar:8.7.1]
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40) ~[vaadin-server-8.7.1.jar:8.7.1]
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1602) ~[vaadin-server-8.7.1.jar:8.7.1]
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:445) ~[vaadin-server-8.7.1.jar:8.7.1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat8-servlet-api-8.0.32.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat8-websocket-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:130) ~[spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:66) ~[spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:105) ~[spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:123) ~[spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) ~[tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat8-catalina-8.0.32.jar:8.0.32]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat8-coyote-8.0.32.jar:8.0.32]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat8-coyote-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1075) [tomcat8-coyote-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.run(Nio2Endpoint.java:1034) [tomcat8-coyote-8.0.32.jar:8.0.32]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat8-util-8.0.32.jar:8.0.32]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]