Spring boot 在Wildfly 10上部署CAS 5.3.3 Maven Overlay WAR的java.lang.ClassCastException

Spring boot 在Wildfly 10上部署CAS 5.3.3 Maven Overlay WAR的java.lang.ClassCastException,spring-boot,cas,wildfly-10,Spring Boot,Cas,Wildfly 10,我正在Wildfly 10上部署CAS 5.3.3,使用中指定的Maven覆盖,并使用以下位置的项目模板: 部署到Wildfly 10后,部署失败,出现以下异常: 09:02:06,982 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 70) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-ho

我正在Wildfly 10上部署CAS 5.3.3,使用中指定的Maven覆盖,并使用以下位置的项目模板:

部署到Wildfly 10后,部署失败,出现以下异常:

09:02:06,982 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 70) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./cas: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./cas: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
     at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
问题可能与Spring引导Maven配置有关。但是,我尝试过这些解决方案,但都不起作用:

这也可能与:

编辑:这是我的POM:

<?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>org.apereo.cas</groupId>
<artifactId>cas-overlay</artifactId>
<packaging>war</packaging>
<version>1.0</version>

<build>
    <plugins>
        <plugin>
            <groupId>com.rimerosolutions.maven.plugins</groupId>
            <artifactId>wrapper-maven-plugin</artifactId>
            <version>0.0.5</version>
            <configuration>
                <verifyDownload>true</verifyDownload>
                <checksumAlgorithm>MD5</checksumAlgorithm>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${springboot.version}</version>
            <configuration>
                <mainClass>${mainClassName}</mainClass>
                <addResources>true</addResources>
                <executable>${isExecutable}</executable>
                <layout>WAR</layout>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>



        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warName>cas</warName>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <recompressZippedFiles>false</recompressZippedFiles>
                <archive>
                    <compress>false</compress>
                    <manifestFile>${manifestFileToUse}</manifestFile>
                </archive>
                <overlays>
                    <overlay>
                        <groupId>org.apereo.cas</groupId>
                        <artifactId>cas-server-webapp${app.server}</artifactId>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
        </plugin>
    </plugins>
    <finalName>cas</finalName>
</build>

<properties>
    <cas.version>5.3.3</cas.version>
    <springboot.version>1.5.14.RELEASE</springboot.version>
    <!-- app.server could be -jetty, -undertow, -tomcat, or blank if you plan to provide appserver -->
    <!-- No ponemos ninguno, para desplegar en WildFly 10 -->
    <app.server></app.server>

    <mainClassName>org.springframework.boot.loader.WarLauncher</mainClassName>
    <isExecutable>false</isExecutable>
    <manifestFileToUse>${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF</manifestFileToUse>

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


<profiles>
    <profile>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <id>default</id>
        <dependencies>
            <dependency>
                <groupId>org.apereo.cas</groupId>
                <artifactId>cas-server-webapp${app.server}</artifactId>
                <version>${cas.version}</version>
                <type>war</type>
                <scope>runtime</scope>
            </dependency>
             <!--
            ...Additional dependencies may be placed here...
            -->
            <!--
            For Wildfly deployment
             -->        

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${springboot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-websocket</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-tomcat</artifactId>
                    </exclusion>
                </exclusions>
             </dependency>               



        </dependencies>
    </profile>

    <profile>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <id>exec</id>
        <properties>
            <mainClassName>org.apereo.cas.web.CasWebApplication</mainClassName>
            <isExecutable>true</isExecutable>
            <manifestFileToUse></manifestFileToUse>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.soebes.maven.plugins</groupId>
                    <artifactId>echo-maven-plugin</artifactId>
                    <version>0.3.0</version>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>echo</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <echos>
                            <echo>Executable profile to make the generated CAS web application executable.</echo>
                        </echos>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

    <profile>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <id>bootiful</id>
        <properties>
            <app.server></app.server>
            <isExecutable>false</isExecutable>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.apereo.cas</groupId>
                <artifactId>cas-server-webapp${app.server}</artifactId>
                <version>${cas.version}</version>
                <type>war</type>
                <scope>runtime</scope>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <id>pgp</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.github.s4u.plugins</groupId>
                    <artifactId>pgpverify-maven-plugin</artifactId>
                    <version>1.1.0</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <pgpKeyServer>hkp://pool.sks-keyservers.net</pgpKeyServer>
                        <pgpKeysCachePath>${settings.localRepository}/pgpkeys-cache</pgpKeysCachePath>
                        <scope>test</scope>
                        <verifyPomFiles>true</verifyPomFiles>
                        <failNoSignature>false</failNoSignature>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

4.0.0
org.apereo.cas
cas覆盖
战争
1
com.rimerosolutions.maven.plugins
包装maven插件
0.0.5
真的
MD5
org.springframework.boot
springbootmaven插件
${springboot.version}
${mainClassName}
真的
${isExecutable}
战争
重新包装
org.apache.maven.plugins
maven战争插件
2.6
中科院
假的
假的
假的
${MANIFESTFILETUSE}
org.apereo.cas
cas服务器webapp${app.server}
org.apache.maven.plugins
maven编译器插件
3.3
中科院
5.3.3
1.5.14.1发布
org.springframework.boot.loader.WarLauncher
假的
${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF
1.8
1.8
UTF-8
真的
违约
org.apereo.cas
cas服务器webapp${app.server}
${cas.version}
战争
运行时
org.springframework.boot
SpringBootStarterWeb
${springboot.version}
org.apache.tomcat.embed
tomcat嵌入websocket
org.springframework.boot
spring启动程序日志记录
org.springframework.boot
弹簧启动机tomcat
假的
执行官
org.apereo.cas.web.CasWebApplication
真的
com.soebes.maven.plugins
echo maven插件
0.3.0
准备包装
回声
可执行配置文件,使生成的CAS web应用程序可执行。
假的
战利品
假的
org.apereo.cas
cas服务器webapp${app.server}
${cas.version}
战争
运行时
假的
pgp
com.github.s4u.plugins
PGP验证maven插件
1.1.0
检查
hkp://pool.sks-keyservers.net
${settings.localRepository}/pgpkeys缓存
测试
真的
假的

最后,我解决了这个问题

CAS War覆盖正在加载两个JAR,我无法排除它们的依赖项标记。问题是这些JAR来自CAS覆盖,它被复制到生成war的WEB-INF/lib中

  • tomcat嵌入websocket-*.jar->java.lang.ClassCastException
  • WEB-INF/lib/log4j-slf4j-*.jar->记录相关异常
因此,我使用excludes将它们从生成的jar中排除

这是最后一个POM,可在Wildfly上正确部署:

<?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>org.apereo.cas</groupId>
<artifactId>cas-overlay</artifactId>
<packaging>war</packaging>
<version>1.0</version>    
<build>
    <plugins>           
        <!-- 
        <plugin>
            <groupId>com.rimerosolutions.maven.plugins</groupId>
            <artifactId>wrapper-maven-plugin</artifactId>
            <version>0.0.5</version>
            <configuration>
                <verifyDownload>true</verifyDownload>
                <checksumAlgorithm>MD5</checksumAlgorithm>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${springboot.version}</version>
            <configuration>
                <mainClass>${mainClassName}</mainClass>
                <addResources>true</addResources>
                <executable>${isExecutable}</executable>
                <layout>WAR</layout>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
         -->             

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <warName>cas</warName>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <recompressZippedFiles>false</recompressZippedFiles>
                <archive>
                    <compress>false</compress>
                    <manifestFile>${manifestFileToUse}</manifestFile>
                </archive>
                <overlays>
                    <overlay>
                        <groupId>org.apereo.cas</groupId>
                        <artifactId>cas-server-webapp${app.server}</artifactId>
                        <excludes>
                            <!-- Exclude these jars from the generated WAR:                                 
                             -->
                            <exclude>WEB-INF/lib/log4j-slf4j-*.jar</exclude>
                            <exclude>WEB-INF/lib/tomcat-embed-websocket-*.jar</exclude>
                        </excludes>
                    </overlay>
                </overlays>                    
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>                
        </plugin>
    </plugins>
    <finalName>cas</finalName>
</build>

<properties>
    <cas.version>5.3.3</cas.version>
    <springboot.version>1.5.14.RELEASE</springboot.version>
    <!-- app.server could be -jetty, -undertow, -tomcat, or blank if you plan to provide appserver -->        
    <app.server></app.server>

    <mainClassName>org.springframework.boot.loader.WarLauncher</mainClassName>       
    <isExecutable>false</isExecutable>
    <manifestFileToUse>${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF</manifestFileToUse>

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

<!-- Corporate repositories -->

<dependencies>
    <dependency>
        <groupId>org.apereo.cas</groupId>
        <artifactId>cas-server-webapp${app.server}</artifactId>
        <version>${cas.version}</version>
        <type>war</type>
        <scope>runtime</scope>
    </dependency>

    <!--
      ...Additional dependencies may be placed here...
      -->                
 </dependencies>    
 </project>

4.0.0
org.apereo.cas
cas覆盖
战争
1
org.apache.maven.plugins
maven战争插件
中科院
假的
假的
假的
${MANIFESTFILETUSE}
org.apereo.cas
cas服务器webapp${app.server}
WEB-INF/lib/log4j-slf4j-*.jar
WEB-INF/lib/tomcat嵌入websocket-*.jar
组织a