【问题标题】:IllegalArgumentException deploying CAS 5.3.10 Maven Overlay WAR on Wildfly 14IllegalArgumentException 在 Wildfly 14 上部署 CAS 5.3.10 Maven 覆盖 WAR
【发布时间】:2019-06-11 12:29:24
【问题描述】:

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

我已经编辑了在 Wildfly 9 上正确部署的 pom,但在 Wildfly 14 上部署失败并出现以下异常:

原因:java.lang.IllegalArgumentException: object is not an 声明类的实例 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at 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)访问以检索与模块的最后修改日期相关的信息。

【问题讨论】:

  • 我遇到了同样的问题。我没有找到解决方案,所以我降级到 wildlfy 12。
  • @leopal 我在 wildfly 14 上成功部署了 War 我验证了 Spring 的 VfsUtils 类仅在 CasVersion 类中使用。此时,在叠加层中,我在项目中创建了 org.apereo.cas.util.CasVersion 类,避免在 getDateTime 方法中使用 VfsResource
  • 很好,请随时回答您的问题,以帮助其他面临同样问题的人。
  • @Marco 我找不到你。你能详细解释一下吗?我实际上被困住了
  • @RaviMCA 您是否尝试过上述评论中提到的 Marco 解决方案?我还没有测试过自己,但我想它会起作用。

标签: maven wildfly war web-deployment cas


【解决方案1】:

由于@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. 将所有出现的&lt;app-server&gt;-tomcat&lt;/app-server&gt; 替换为&lt;app-server&gt;&lt;/app-server&gt;,因为您将提供应用程序服务器。

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

【讨论】:

    猜你喜欢
    • 2019-02-23
    • 2014-12-07
    • 1970-01-01
    • 2015-08-07
    • 2018-05-12
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多