Vaadin Spring Projekt期望no-arg构造函数,只在tomcat上不是本地的

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vaadin Spring Projekt期望no-arg构造函数,只在tomcat上不是本地的相关的知识,希望对你有一定的参考价值。

我试图在Ubuntu 18.04服务器上的Tomcat应用程序服务器上运行Spring Boot的Vaadin projekt。

我下载了Vaadin Flow Spring Starter Projekt:https://vaadin.com/start/latest/project-base-spring

但是当我在tomcat上部署并尝试打开它时,我收到此错误:

There was an exception while trying to navigate to '' with the exception message 'Unable to create an instance of 'de.web.michail.spring.MainView'. Make sure the class has a public no-arg constructor.'
java.lang.IllegalArgumentException: Unable to create an instance of 'de.web.michail.spring.MainView'. Make sure the class has a public no-arg constructor.
    at com.vaadin.flow.internal.ReflectTools.createProxyInstance(ReflectTools.java:515)
    at com.vaadin.flow.internal.ReflectTools.createInstance(ReflectTools.java:447)
    at com.vaadin.flow.di.DefaultInstantiator.getOrCreate(DefaultInstantiator.java:65)
    at com.vaadin.flow.di.Instantiator.createRouteTarget(Instantiator.java:158)
    at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.lambda$getRouteTarget$1(AbstractNavigationStateRenderer.java:116)
    at java.base/java.util.Optional.orElseGet(Optional.java:358)
    at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.getRouteTarget(AbstractNavigationStateRenderer.java:115)
    at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.handle(AbstractNavigationStateRenderer.java:167)
    at com.vaadin.flow.router.Router.handleNavigation(Router.java:221)
    at com.vaadin.flow.router.Router.navigate(Router.java:192)
    at com.vaadin.flow.router.Router.initializeUI(Router.java:95)
    at com.vaadin.flow.server.BootstrapHandler.createAndInitUI(BootstrapHandler.java:1117)
    at com.vaadin.flow.server.BootstrapHandler.synchronizedHandleRequest(BootstrapHandler.java:396)
    at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
    at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1533)
    at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:227)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:844)

我不明白这个基本示例项目是如何运行的。你是tomcat的问题吗?也许像WildFly这样的其他应用程序服务器会运行正确吗?

答案

让Application扩展SpringBootServletInitializer解决了这个问题。

public class Application extends SpringBootServletInitializer {
// ...
}

以上是关于Vaadin Spring Projekt期望no-arg构造函数,只在tomcat上不是本地的的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 Spring Security 保护 Vaadin 流应用程序

带有 Spring MVC 的 Vaadin 8 Spring Boot QuickTickets 仪表板

使用 Vaadin 和 Spring (MySQL DB) 运行应用程序时出现问题

使用带有 Spring Security 的 Vaadin 出现 403 CSRF 令牌错误

Vaadin 8(没有 Spring Boot/Security)和 Keycloak 不起作用

为啥 spring-vaadin 忘记了我设置的 locale,但在页面刷新后突然记住了?