Spring Boot Websockets in Wildfly

前端 未结 5 1734
星月不相逢
星月不相逢 2020-12-15 04:14

Hi I need to deploy my Spring Boot app into Wildfly 8.1 and I\'m getting the following exception:

Caused by: java.lang.RuntimeException: java.lang.Cl

相关标签:
5条回答
  • 2020-12-15 04:29

    I'm not sure, but your POM around websockets should be like this:

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

    spring-messaging, spring-websocket, jackson-databind, spring-boot-starter-web are redundant.

    There is also spring-boot-starter-thymeleaf.

    However I think the root of your cause is tomcat-embed-websocket.

    0 讨论(0)
  • 2020-12-15 04:32

    For me , spring-boot-starter-websocket and spring-boot-starter-web by default includes the spring-boot-starter-tomcat so exclude the tomcat, like below without version of spring boot:

    <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>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
    0 讨论(0)
  • 2020-12-15 04:39

    spring-boot-starter-web and spring-boot-starter-websocket by default includes the spring-boot-starter-tomcat so exclude the tomcat, like below

         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring-boot.version}</version>
            <exclusions>
                <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-websocket</artifactId>
            <version>${spring-boot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    and include undertow, make sure the tomcat exists no where in the classpath.

    0 讨论(0)
  • 2020-12-15 04:45

    You need exclude tomcat-embed-websocket

    <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>
            </exclusions>
        </dependency>
    
    0 讨论(0)
  • 2020-12-15 04:46

    Use the following command to find all dependencies that includes spring-boot-starter-tomcat:

    mvn dependency:tree -Dincludes=org.springframework.boot:spring-boot-starter-tomcat
    

    Exclude Tomcat starter from all your dependencies listed by this command.

    After that, you might need to add javax.servlet-api as a provided dependency:

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

    Gradle users with this issue: check out the comments on this ticket: https://github.com/spring-projects/spring-boot/issues/6166

    0 讨论(0)
提交回复
热议问题