首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >java.lang.ClassCastException部署CASC5.3.3Maven覆盖战争在野生蝇10上

java.lang.ClassCastException部署CASC5.3.3Maven覆盖战争在野生蝇10上
EN

Stack Overflow用户
提问于 2018-09-19 07:28:54
回答 1查看 712关注 0票数 1

我正在野生蝇10上部署CAS 5.3.3,使用https://apereo.github.io/cas/5.3.x/installation/Maven-Overlay-Installation.html中指定的Maven覆盖,并使用项目模板at:https://github.com/apereo/cas-overlay-template/tree/5.3

部署到Wildfly 10之后,除以下例外情况外,部署将失败:

代码语言:javascript
复制
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配置有关。然而,我尝试过这些解决方案,但它们没有奏效:

这也可能与以下方面有关:

https://groups.google.com/a/apereo.org/forum/#!topic/cas-user/Buzbh5XpnlI https://docs.spring.io/spring-boot/docs/1.5.14.RELEASE/reference/htmlsingle/#howto-create-a-deployable-war-file

编辑:这是我的POM:

代码语言:javascript
复制
<?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>

EN

回答 1

Stack Overflow用户

发布于 2018-09-20 11:00:19

最后,我解决了它。

CAS War覆盖正在加载两个War,我不能排除按照提供的方式标记它们的依赖项。问题是这些war来自CAS覆盖,它被复制到war的WEB/lib中。

  • tomcat-embed websocket-*..jar -> java.lang.ClassCastException
  • WEB/lib/log4j-slf4j-*..jar与->日志记录相关的异常

因此,我将它们排除在生成的jar中,使用的是“排除”。

https://maven.apache.org/plugins/maven-war-plugin/overlays.html

这是最后一个POM,它正确地部署在野生蝇上:

代码语言:javascript
复制
<?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>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52400434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档