Deploying an app using vaadin 14.0.7 to kubernetes does not work, because there is of course no 'npm' and 'node' installed.
From the POD log:
2019-10-06 13:12:53.486 INFO [gateway-service,,,] 1 --- [ restartedMain] dev-updater : Running `npm install` ...
2019-10-06 13:12:53.492 ERROR [gateway-service,,,] 1 --- [ restartedMain] c.v.f.s.frontend.FrontendToolsLocator : Command '[which, npm]' failed with exit code '1'
2019-10-06 13:12:53.501 ERROR [gateway-service,,,] 1 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener]
java.lang.RuntimeException: Unable to initialize Vaadin DevModeHandler
at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:326) ~[vaadin-spring-12.0.6.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4683) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:459) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:105) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:416) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:180) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at com.example.gatewayservice.GatewayServiceApplication.main(GatewayServiceApplication.java:16) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.1.9.RELEASE.jar:2.1.9.RELEASE]
Caused by: javax.servlet.ServletException: com.vaadin.flow.server.ExecutionFailedException:
======================================================================================================
Failed to determine 'npm' tool.
Please install it either:
- by following the https://nodejs.org/en/download/ guide to install it globally
- or by running the frontend-maven-plugin goal to install it in this project:
$ mvn com.github.eirslett:frontend-maven-plugin:1.7.6:install-node-and-npm -DnodeVersion="v10.16.0"
======================================================================================================
at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:327) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:323) ~[vaadin-spring-12.0.6.jar:na]
... 43 common frames omitted
Caused by: com.vaadin.flow.server.ExecutionFailedException:
======================================================================================================
Failed to determine 'npm' tool.
Please install it either:
- by following the https://nodejs.org/en/download/ guide to install it globally
- or by running the frontend-maven-plugin goal to install it in this project:
$ mvn com.github.eirslett:frontend-maven-plugin:1.7.6:install-node-and-npm -DnodeVersion="v10.16.0"
======================================================================================================
at com.vaadin.flow.server.frontend.TaskRunNpmInstall.runNpmInstall(TaskRunNpmInstall.java:82) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.server.frontend.TaskRunNpmInstall.execute(TaskRunNpmInstall.java:55) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.server.frontend.NodeTasks.execute(NodeTasks.java:372) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:322) ~[flow-server-2.0.14.jar:2.0.14]
... 44 common frames omitted
Caused by: java.lang.IllegalStateException:
======================================================================================================
Failed to determine 'npm' tool.
Please install it either:
- by following the https://nodejs.org/en/download/ guide to install it globally
- or by running the frontend-maven-plugin goal to install it in this project:
$ mvn com.github.eirslett:frontend-maven-plugin:1.7.6:install-node-and-npm -DnodeVersion="v10.16.0"
======================================================================================================
at com.vaadin.flow.server.frontend.FrontendUtils.getExecutable(FrontendUtils.java:292) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.server.frontend.FrontendUtils.getNpmExecutable(FrontendUtils.java:250) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.server.frontend.TaskRunNpmInstall.runNpmInstall(TaskRunNpmInstall.java:79) ~[flow-server-2.0.14.jar:2.0.14]
... 47 common frames omitted
2019-10-06 13:12:53.506 ERROR [gateway-service,,,] 1 --- [ restartedMain] o.apache.catalina.core.StandardContext : One or more listeners failed to start. Full details will be found in the appropriate container log file
2019-10-06 13:12:53.506 ERROR [gateway-service,,,] 1 --- [ restartedMain] o.apache.catalina.core.StandardContext : Context [] startup failed due to previous errors
2019-10-06 13:12:53.510 WARN [gateway-service,,,] 1 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [AsyncReporter{org.springframework.cloud.sleuth.zipkin2.sender.RestTemplateSender@20e1894a}] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@11/jdk.internal.misc.Unsafe.park(Native Method)
java.base@11/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
java.base@11/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
app//zipkin2.reporter.ByteBoundedQueue.drainTo(ByteBoundedQueue.java:81)
app//zipkin2.reporter.AsyncReporter$BoundedAsyncReporter.flush(AsyncReporter.java:256)
app//zipkin2.reporter.AsyncReporter$Flusher.run(AsyncReporter.java:354)
java.base@11/java.lang.Thread.run(Thread.java:834)
2019-10-06 13:12:53.529 INFO [gateway-service,,,] 1 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-10-06 13:12:53.532 WARN [gateway-service,,,] 1 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
So, how to run this app in kubernetes?
Ok... tried:
vaadin:
compatibilityMode: true
From POD-log:
2019-10-06 13:31:49.965 WARN [gateway-service,0e9b0bbbb058a082,0e9b0bbbb058a082,true] 1 --- [p-nio-80-exec-9] c.v.f.s.DefaultDeploymentConfiguration :
====================================================================
Running in Vaadin 13 (Flow 1) compatibility mode.
This mode uses webjars/Bower for client side dependency management and HTML imports for dependency loading.
The default mode in Vaadin 14+ (Flow 2+) is based on npm for dependency management and JavaScript modules for dependency inclusion.
See http://vaadin.com/docs for more information.
====================================================================
and
2019-10-06 13:32:08.828 ERROR [gateway-service,9b6f4d0199ce43c0,9b6f4d0199ce43c0,true] 1 --- [-nio-80-exec-11] c.v.flow.server.DefaultErrorHandler :
java.lang.IllegalStateException: Couldn't find the definition of the element with tag 'clickable-card' in any template file declared using @'HtmlImport' annotations. Check the availability of the template files in your WAR file or provide alternative implementation of the method getTemplateContent() which should return an element representing the content of the template file
at com.vaadin.flow.component.polymertemplate.DefaultTemplateParser.getTemplateContent(DefaultTemplateParser.java:128) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.component.polymertemplate.TemplateDataAnalyzer.parseTemplate(TemplateDataAnalyzer.java:200) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.component.polymertemplate.TemplateInitializer.<init>(TemplateInitializer.java:91) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:88) ~[flow-server-2.0.14.jar:2.0.14]
at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:103) ~[flow-server-2.0.14.jar:2.0.14]
at com.github.appreciated.card.AbstractCard.<init>(AbstractCard.java:22) ~[card-2.0.0.beta3.jar:2.0.0.beta3]
at com.github.appreciated.card.ClickableCard.<init>(ClickableCard.java:41) ~[card-2.0.0.beta3.jar:2.0.0.beta3]
at com.github.appreciated.card.ClickableCard.<init>(ClickableCard.java:37) ~[card-2.0.0.beta3.jar:2.0.0.beta3]
at com.example.gatewayservice.ProduktCard.<init>(ProduktCard.java:11) ~[classes/:na]
Note: all works fine if i start the app in intellij. after deploying to k8s the app stops working...
Moving to Flow team for investigations
Do you have a reason to deploy an app in dev mode ?
Dev mode requires node and npm installed and this you may do normally locally.
You need them (or they should be installed) to be able to use dev mode: this is a limitation.
If you deploy an application to the production server then it doesn't have to have node/npm.
You should use production mode.
https://github.com/vaadin/flow-and-components-documentation/blob/master/documentation/production/tutorial-production-mode-basic.asciidoc
That's about the NPM mode.
It's possible to use compatibility mode.
In this case you may not use JsModule annotations.
Do you want to use it so that it has sense to discuss it ?
If you have problems with compatibility mode which you want to solve then please provide a way which you use to configure your project to use compatibility mode: apparently you have difference between project locally run and deployed. There should not be any difference. So I suppose the configuration for local execution and remote application is different.
Thanks for the hint and link!
I've got similar issues. My Pom looks like:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>backoffice</artifactId>
<groupId>io.rocketbase.orderbucket</groupId>
<version>LATEST-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>backoffice-ui</artifactId>
<repositories>
<repository>
<id>Vaadin Directory</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.rocketbase.orderbucket</groupId>
<artifactId>backoffice-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.rocketbase.vaadin</groupId>
<artifactId>vaadin-rocketbase-flow</artifactId>
<version>${vaadin-rocketbase-flow.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- vaadin sticks to 2.5 instead of 2.2.... -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<!-- Spring & Co. -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.rocketbase.commons</groupId>
<artifactId>commons-auth-forms</artifactId>
<version>${commons-auth.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>prepare-frontend</goal>
<goal>build-frontend</goal>
</goals>
</execution>
</executions>
<configuration>
<compatibilityMode>false</compatibilityMode>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>production</id>
<properties>
<vaadin.productionMode>true</vaadin.productionMode>
</properties>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-server-production-mode</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
my vaadin.version is 14.0.10
I build my project with
mvn package -Pproduction
and still i got the dev-updater promted in my running application and it tries to run npm install
FROM openjdk:8-jre-alpine
COPY app.jar /opt/application/app.jar
WORKDIR /opt/application/
EXPOSE 5050
ENTRYPOINT java -Djava.security.egd=file:/dev/urandom -Xmx1024m -Xss256k -jar app.jar
Do i need to add any parameter to my docker run file? The documentation is not that clear in this point.
I've solved my problem by adding -Dvaadin.productionMode to my docker ENTRYPOINT
Most helpful comment
I've solved my problem by adding -Dvaadin.productionMode to my docker ENTRYPOINT