[Wildfly 14上部署CAS 5.3.10 Maven覆盖WAR的IllegalArgumentException

问题描述 投票:5回答:1

我正在使用https://apereo.github.io/cas/5.3.x/installation/Configuring-Servlet-Container.html#external中指定的Maven叠加层在Wildfly 14上部署CAS 5.3.10,并在以下位置使用项目模板:https://github.com/apereo/cas-overlay-template/tree/5.3

我已经编辑了可以在Wildfly 9上正确部署的pom,但是在Wildfly 14上部署失败,但有以下例外:

原因:java.lang.IllegalArgumentException:对象不是在声明类的实例sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)位于sun.reflect.DelegatingMethodAccessorImpl.invoke(未知源)位于java.lang.reflect.Method.invoke(来源未知)org.springframework.core.io.VfsUtils.invokeVfsMethod(VfsUtils.java:100)在org.springframework.core.io.VfsUtils.getFile(VfsUtils.java:172)在org.springframework.core.io.VfsResource.getFile(VfsResource.java:90)在org.apereo.cas.util.CasVersion.getDateTime(CasVersion.java:59)处org.apereo.cas.util.SystemUtils.getSystemInfo(SystemUtils.java:50)...........

问题似乎与CasVersion类有关,该类试图通过VFS(通过spring)进行访问以检索与模块的最后修改日期有关的信息。

maven wildfly war web-deployment cas
1个回答
2
投票

由于@Marco没有提供他的解决方案,我会的。对于遇到相同问题的任何人,请按照以下步骤解决:

  1. [签出cas-overlay-template后,创建CasVersion.javasrc/main/java/org/apereo/cas/util下具有以下内容:
package org.apereo.cas.util;

import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.VfsResource;

import java.io.File;
import java.net.URL;
import java.time.ZonedDateTime;


/**
 1. Class that exposes the CAS version. Fetches the "Implementation-Version"
 2. manifest attribute from the jar file.
 3.  4. @author Dmitriy Kopylenko
 4. @since 3.0.0
 */
@Slf4j
@UtilityClass
public class CasVersion {

    /**
     * @return Return the full CAS version string.
     * @see java.lang.Package#getImplementationVersion
     */
    public static String getVersion() {
        return CasVersion.class.getPackage().getImplementationVersion();
    }

    /**
     * Gets specification version from the manifest package.
     *
     * @return the specification version
     */
    public static String getSpecificationVersion() {
        return CasVersion.class.getPackage().getSpecificationVersion();
    }

    /**
     * Gets last modified date/time for the module.
     *
     * @return the date/time
     */
    @SneakyThrows
    public static ZonedDateTime getDateTime() {
        final Class clazz = CasVersion.class;
        final URL resource = clazz.getResource(clazz.getSimpleName() + ".class");
        if ("file".equals(resource.getProtocol())) {
            return DateTimeUtils.zonedDateTimeOf(new File(resource.toURI()).lastModified());
        }
        if ("jar".equals(resource.getProtocol())) {
            final String path = resource.getPath();
            final File file = new File(path.substring(5, path.indexOf('!')));
            return DateTimeUtils.zonedDateTimeOf(file.lastModified());
        }
        // These lines are causing the reported exception so we just comment them out.
        // if ("vfs".equals(resource.getProtocol())) {
        //     final File file = new VfsResource(resource.openConnection().getContent()).getFile();
        //     return DateTimeUtils.zonedDateTimeOf(file.lastModified());
        // }
        LOGGER.warn("Unhandled url protocol: [{}] resource: [{}]", resource.getProtocol(), resource);
        return ZonedDateTime.now();
    }
}
  1. 将以下依赖项添加到pom.xml
    <!-- Required for lombok imports -->              
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.16</version>
        <scope>provided</scope>
    </dependency>  
    <!-- Required for DateTimeUtils to be available on classpath -->              
    <dependency>
        <groupId>org.apereo.cas</groupId>
        <artifactId>cas-server-core-util</artifactId>
        <version>${cas.version}</version>
    </dependency>
  1. 由于要提供应用程序服务器,因此将<app-server>-tomcat</app-server>的所有出现位置替换为<app-server></app-server>

上述步骤应足以解决已报告的问题

© www.soinside.com 2019 - 2024. All rights reserved.