Deploy Vaadin 10+ flow to a standalone Tomcat

Hello dear Vaadin Users / Team

I have a small Raspberry Pi with Tomcat8 which in the past, i successfully used with Vaadin 7/8 for some nice little web applications with live sensor data. To get a application onto the server, i simply used the pom.xml configuration

<plugin>
	<groupId>org.apache.tomcat.maven</groupId>
	<artifactId>tomcat7-maven-plugin</artifactId>
	<version>2.1</version>
	<configuration>
		<server>tomcat8</server>
		<url>http://x.x.x.x:8080/manager/text</url>
	</configuration>
</plugin>

and a maven settings file with the needed tomcat-user details for the tomcat-manager authentication.
All i needed to deploy the application on the server was to run Maven with the goal tomcat:deploy.

I was no longer able to reproduce this with the Vaadin 10+ default project of the Eclipse marketplace Vaadin plugin.
Even altering the pom to produce a war instead of a jar file and uploading it manually was fruitless.
Is it still possible to do something similar (to get the application configured so that maven can deploy it automatically)?

Hi,

I don’t know this plugin but I think you need to try to fix the manual upload.
It could fix the automatic deployment.

Can you post you entire pom.xml? What is in your log?

One thing that could help: You should build your war in production mode:
mvn clean package -Pproduction

You have some information here: https://vaadin.com/docs/v14/flow/production/deploying-spring-boot-apps.html

First of all, thank you for your help, Jean-Christophe.

I did some more digging and found a old project of mine where i did experiment with Vaadin 10.
There i got the configuration working.
By combining parts of the old and new pom, i got the my-starter-project (the simple base project created without any package ore classname changes). Now i can like before directly deploy the application (via the goal tomcat:deploy -Pproduction to the Tomcat server hosted by the Raspberry Pi. The things that needed changing were the build and profiles section of the pom.

For those interested by the solution:

<?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">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.example.test</groupId>
	<artifactId>my-starter-project</artifactId>
	<name>My Starter Project</name>
	<version>1.0-SNAPSHOT</version>
	<packaging>war</packaging>

	<properties>
		<java.version>1.8</java.version>
		<vaadin.version>14.4.7</vaadin.version>
	</properties>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.2</version>
	</parent>

	<repositories>
		<!-- The order of definitions matters. Explicitly defining central here 
			to make sure it has the highest priority. -->

		<!-- Main Maven repository -->
		<repository>
			<id>central</id>
			<url>https://repo.maven.apache.org/maven2</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<!-- Repository used by many Vaadin add-ons -->
		<repository>
			<id>Vaadin Directory</id>
			<url>https://maven.vaadin.com/vaadin-addons</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>

	<pluginRepositories>
		<!-- Main Maven repository -->
		<pluginRepository>
			<id>central</id>
			<url>https://repo.maven.apache.org/maven2</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.vaadin</groupId>
				<artifactId>vaadin-bom</artifactId>
				<version>${vaadin.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>com.vaadin</groupId>
			<!-- Replace artifactId with vaadin-core to use only free components -->
			<artifactId>vaadin</artifactId>
			<exclusions>
				<!-- Webjars are only needed when running in Vaadin 13 compatibility 
					mode -->
				<exclusion>
					<groupId>com.vaadin.webjar</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.insites</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.polymer</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.polymerelements</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.vaadin</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.webcomponents</groupId>
					<artifactId>*</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-spring-boot-starter</artifactId>
			<exclusions>
				<!-- Excluding so that webjars are not included. -->
				<exclusion>
					<groupId>com.vaadin</groupId>
					<artifactId>vaadin-core</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-testbench</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.github.bonigarcia</groupId>
			<artifactId>webdrivermanager</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.0</version>
			</plugin>

			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.1</version>
				<configuration>
					<server>tomcat</server>
					<url>http://xxx.xxx.xxx.xxx:8080/manager/text</url>
					<scanIntervalSeconds>2</scanIntervalSeconds>
					<!-- Use war output directory to get the webpack files -->
					<webAppConfig>
						<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
					</webAppConfig>
				</configuration>
			</plugin>

			<!-- Take care of synchronizing java dependencies and imports in package.json 
				and main.js files. It also creates webpack.config.js if not exists yet. -->
			<plugin>
				<groupId>com.vaadin</groupId>
				<artifactId>vaadin-maven-plugin</artifactId>
				<version>${vaadin.version}</version>
				<executions>
					<execution>
						<goals>
							<goal>prepare-frontend</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.github.eirslett</groupId>
				<artifactId>frontend-maven-plugin</artifactId>
				<!-- Use the latest released version: https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
				<version>1.8.0</version>

				<executions>
					<execution>
						<!-- optional: you don't really need execution ids, but it looks nice 
							in your build log. -->
						<id>install node and npm</id>
						<goals>
							<goal>install-node-and-npm</goal>
						</goals>
						<!-- optional: default phase is "generate-resources" -->
						<phase>generate-resources</phase>
					</execution>
				</executions>
				<configuration>
					<nodeVersion>v10.16.3</nodeVersion>

					<!-- optional: with node version greater than 4.0.0 will use npm provided 
						by node distribution -->
					<!-- <npmVersion>2.15.9</npmVersion> -->

					<!-- optional: where to download node and npm from. Defaults to https://nodejs.org/dist/ -->
					<!-- <downloadRoot>http://myproxy.example.org/nodejs/</downloadRoot> -->
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<!-- Production mode is activated using -Pproduction -->
			<id>production</id>
			<properties>
				<vaadin.productionMode>true</vaadin.productionMode>
			</properties>

			<dependencies>
				<dependency>
					<groupId>com.vaadin</groupId>
					<artifactId>flow-server-production-mode</artifactId>
				</dependency>
			</dependencies>

			<build>
				<plugins>
					<plugin>
						<groupId>com.vaadin</groupId>
						<artifactId>vaadin-maven-plugin</artifactId>
						<executions>
							<execution>
								<goals>
									<goal>build-frontend</goal>
								</goals>
								<phase>compile</phase>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.apache.tomcat.maven</groupId>
						<artifactId>tomcat7-maven-plugin</artifactId>
						<version>2.1</version>
						<configuration>
							<server>tomcat</server>
							<url>http://xxx.xxx.xxx.xxx:8080/manager/text</url>
							<scanIntervalSeconds>2</scanIntervalSeconds>
							<!-- Use war output directory to get the webpack files -->
							<webAppConfig>
								<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
							</webAppConfig>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>


	</profiles>
</project>