java.lang.ClassCastException развертывание CAS 5.3.3 WAR-оверлей Maven на Wildfly 10 - PullRequest
0 голосов
/ 19 сентября 2018

Я развертываю CAS 5.3.3 на Wildfly 10, используя наложение Maven, как указано в https://apereo.github.io/cas/5.3.x/installation/Maven-Overlay-Installation.html, и использую шаблон проекта по адресу: https://github.com/apereo/cas-overlay-template/tree/5.3

После развертывания на 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 Boot Maven.Однако я попробовал эти решения, но они не работают:

Может быть связанотакже:

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:

<?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>

1 Ответ

0 голосов
/ 20 сентября 2018

Наконец, я решил это.

Оверлей CAS War загружал две банки, которые я не мог исключить, помечая их зависимости как предоставленные.Проблема в том, что эти файлы были получены из оверлея CAS, они были скопированы в WEB-INF / lib сгенерированной войны.

  • tomcat-embed-websocket - *. Jar -> java.lang.ClassCastException
  • WEB-INF / lib / log4j-slf4j - *. Jar -> Исключение, связанное с журналированием

Поэтому я исключил их из сгенерированного jar, используя exclude.

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

Это последний 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>
...