WildFly 14:无法将类org.apache.tomcat.websocket.server.WsServerContainer强制转换为类io.undertow.websockets.jsr.ServerWebSocketContainer

时间:2019-01-13 18:43:52

标签: spring-boot wildfly web-deployment

尝试将Spring Boot应用程序部署到WildFly 14我得到以下错误:

  

{“ WFLYCTL0080:服务失败” => {“ jboss.deployment.unit。\” application_name \“。undertow-deployment” =>“ java.lang.RuntimeException:java.lang.ClassCastException:org.apache类。无法将tomcat.websocket.server.WsServerContainer强制转换为类io.undertow.websockets.jsr.ServerWebSocketContainer(org.apache.tomcat.websocket.server.WsServerContainer位于加载程序'deployment.application_name.war'@ 56a6a8b7; io的未命名模块中.undertow.websockets.jsr.ServerWebSocketContainer位于加载器'io.undertow.websocket@2.0.13.Final'@ 59ba0563的未命名模块中)       引起原因:java.lang.RuntimeException:java.lang.ClassCastException:org.apache.tomcat.websocket.server.WsServerContainer类不能转换为io.undertow.websockets.jsr.ServerWebSocketContainer类(org.apache.tomcat.websocket。 server.WsServerContainer在加载器'deployment.application_name.war'的未命名模块中@ 56a6a8b7; io.undertow.websockets.jsr.ServerWebSocketContainer在加载器'io.undertow.websocket@2.0.13.Final'@ 59ba0563的未命名模块中       造成原因:java.lang.ClassCastException:org.apache.tomcat.websocket.server.WsServerContainer类无法转换为io.undertow.websockets.jsr.ServerWebSocketContainer类(org.apache.tomcat.websocket.server.WsServerContainer处于未命名状态加载程序'deployment.application_name.war'的模块@ 56a6a8b7; io.undertow.websockets.jsr.ServerWebSocketContainer位于加载程序'io.undertow.websocket@2.0.13.Final'@ 59ba0563)的未命名模块中)}}

我已经尝试了在stackoverflow或其他博客,论坛等中可以找到的所有内容,但是没有运气。我结束了下面的pom.xml。

<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.foo.application_name</groupId>
<artifactId>application_name</artifactId>
<version>xxx</version>

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

<dependencies>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.0.1</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
       <exclusions>
           <exclusion>
               <groupId>org.apache.tomcat.embed</groupId>
               <artifactId>tomcat-embed-websocket</artifactId>
           </exclusion>
           <exclusion>
               <groupId> org.springframework.boot</groupId>
               <artifactId> spring-boot-starter-tomcat</artifactId>
           </exclusion>
       </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-model</artifactId>
        <version>3.5.4</version>
    </dependency>
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>tomcat-embed-el</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <!-- update Hibernate dependency on Javassist to 3.23.1 for Java 11 compatibility -->
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.23.1-GA</version>
    </dependency>
    <dependency>
        <!-- update Mockito dependency for Java 11 compatibility -->
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>2.22.0</version><!--$NO-MVN-MAN-VER$ -->
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.12</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

<packaging>war</packaging>

<build>
    <defaultGoal>install</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
                <skipTests>true</skipTests>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

有人可以检查我的pom.xml并告诉我我缺少什么吗?

1 个答案:

答案 0 :(得分:0)

您必须将 spring-boot-starter-underow 设置为 scope = 提供。这对任何其他网络服务器都很重要。