我通过gradle以生产模式构建了Vaadin项目。
在这里build.gradle.kts
plugins {
kotlin("jvm") version "1.3.20"
id("com.github.johnrengelman.shadow") version "4.0.3"
id("com.devsoap.vaadin-flow") version "1.0"
id("org.gretty") version "2.3.1"
id("war")
}
val kotlinVersion = "1.3.20" //by extra("1.3.20")
val jettyVersion = "9.4.14.v20181114"
val vaadinVersion = "12.0.4"
val jettyDep = { dep: String, suffix: String ->
"org.eclipse.jetty${if (suffix.isNotEmpty()) ".$suffix" else suffix}:$dep:$jettyVersion"
}
vaadin.autoconfigure()
vaadin {
setProductionMode(true)
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("com.github.jengelman.gradle.plugins:shadow:4.0.3")
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
implementation("com.vaadin:vaadin-bom:$vaadinVersion")
implementation("com.vaadin:vaadin-core:$vaadinVersion")
//implementation("com.vaadin:flow-server-production-mode:1.4.0") // Switch to production mode
implementation("com.github.mvysny.karibudsl:karibu-dsl-v10:0.6.2")
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("javax.servlet:javax.servlet-api:3.1.0")
implementation(jettyDep("jetty-plus", ""))
implementation(jettyDep("jetty-continuation", ""))
implementation(jettyDep("jetty-server", ""))
implementation(jettyDep("websocket-server", "websocket"))
implementation(jettyDep("javax-websocket-server-impl", "websocket"))
implementation("com.auth0:java-jwt:3.7.0")
implementation("org.reflections:reflections:0.9.11")
}
通过命令成功创建生产模式战争:
gradlew assemble
好。 但是当我向Tomcat 9部署战争时,我得到了错误:
18-Mar-2019 19:23:07.310 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
18-Mar-2019 19:23:07.314 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [831] milliseconds
18-Mar-2019 19:23:07.342 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
18-Mar-2019 19:23:07.342 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.16]
18-Mar-2019 19:23:07.368 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [D:\Programs\apache-tomcat-9.0.16\webapps\booking-sailero-1.0-SNAPSHOT.war]
19:23:28.496 [main] DEBUG org.eclipse.jetty.util.log - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog
19:23:28.506 [main] INFO org.eclipse.jetty.util.log - Logging initialized @22304ms to org.eclipse.jetty.util.log.Slf4jLog
18-Mar-2019 19:23:32.302 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Error during ServletContainerInitializer processing
javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable
at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.onStartup(WebSocketServerContainerInitializer.java:200)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5125)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
18-Mar-2019 19:23:32.307 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [/booking-sailero-1.0-SNAPSHOT] startup failed due to previous errors
18-Mar-2019 19:23:32.338 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [D:\Programs\apache-tomcat-9.0.16\webapps\booking-sailero-1.0-SNAPSHOT.war] has finished in [24,969] ms
18-Mar-2019 19:23:32.340 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [D:\Programs\apache-tomcat-9.0.16\webapps\karibu10-helloworld-application.war]
18-Mar-2019 19:23:34.874 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enab
答案 0 :(得分:1)
我认为您的dependencies
列表中的Jetty条目会导致Jetty类最终进入.war
并因此也进入类路径。其中一些类具有一些通用的Servlet API注释,这些注释由Tomcat拾取,Tomcat会尝试在服务器启动期间进行初始化。