Spring and Wildfly 16

Hi,

I am trying to setup a Vaadin flow project with Spring and Wildfly 16. Keep getting this error during Wildfly start and can’t seem to see what I am doing wrong?

java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer

Read up on ways to resolve it but can’t seem to get rid of the problem. Any help is greatly appreciated. Please see the pom.xml below.

<?xml version="1.0" encoding="UTF-8"?>


4.0.0
com.example
demo
Project base for Vaadin Flow and Spring Boot
0.0.1-SNAPSHOT
war

<properties>
	<maven.compiler.source>1.8</maven.compiler.source>
	<maven.compiler.target>1.8</maven.compiler.target>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

	<!-- Dependencies -->
	<vaadin.version>12.0.7</vaadin.version>
</properties>

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

<repositories>
	<repository>
		<id>Vaadin Directory</id>
		<url>http://maven.vaadin.com/vaadin-addons</url>
	</repository>
</repositories>

<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>
		<artifactId>vaadin-spring-boot-starter</artifactId>
		</dependency>

	<!-- Spring -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-tomcat</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-logging</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-stream-reactive -->
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-stream-reactive</artifactId>
		<version>2.2.0.RELEASE</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-util -->
	<dependency>
		<groupId>org.apache.tomcat</groupId>
		<artifactId>tomcat-util</artifactId>
		<version>9.0.21</version>
	</dependency>

	<!-- other -->
	<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>javax.servlet-api</artifactId>
		<scope>provided</scope>
	</dependency>


</dependencies>

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>

<profiles>
	<profile>
		<!-- Production mode can be activated with either property or profile -->
		<id>production-mode</id>
		<activation>
			<property>
				<name>vaadin.productionMode</name>
			</property>
		</activation>
		<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>
					<version>${vaadin.version}</version>
					<executions>
						<execution>
							<goals>
								<goal>copy-production-files</goal>
								<goal>package-for-production</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
				<plugin>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-maven-plugin</artifactId>
					<configuration>
						<jvmArguments>-Dvaadin.productionMode</jvmArguments>
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>

I was able to spin up Wildfly 16 finally without errors. However, after deploying the .war, I’m getting a forbidden error :-(.

For those planning to work with Vaadin/Spring/Wildfly, see the associated pom.xml below.

<?xml version="1.0" encoding="UTF-8"?>


4.0.0
com.example
demo
Project base for Vaadin Flow and Spring Boot
0.0.1-SNAPSHOT
war

<properties>
	<maven.compiler.source>1.8</maven.compiler.source>
	<maven.compiler.target>1.8</maven.compiler.target>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

	<!-- Dependencies -->
	<vaadin.version>12.0.7</vaadin.version>
</properties>

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

<repositories>
	<repository>
		<id>Vaadin Directory</id>
		<url>http://maven.vaadin.com/vaadin-addons</url>
	</repository>
</repositories>

<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>
		<artifactId>vaadin-spring-boot-starter</artifactId>
	</dependency>

	<!-- Spring -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-tomcat</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-logging</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-tomcat</artifactId>
		<scope>provided</scope>
	</dependency>

	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-stream-reactive</artifactId>
		<version>2.2.0.RELEASE</version>
	</dependency>

	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>javax.servlet-api</artifactId>
		<scope>provided</scope>
	</dependency>

	<!-- <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-util</artifactId> 
		<version>9.0.21</version> </dependency> -->

</dependencies>

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>

<profiles>
	<profile>
		<!-- Production mode can be activated with either property or profile -->
		<id>production-mode</id>
		<activation>
			<property>
				<name>vaadin.productionMode</name>
			</property>
		</activation>
		<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>
					<version>${vaadin.version}</version>
					<executions>
						<execution>
							<goals>
								<goal>copy-production-files</goal>
								<goal>package-for-production</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
				<plugin>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-maven-plugin</artifactId>
					<configuration>
						<jvmArguments>-Dvaadin.productionMode</jvmArguments>
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>