I'm deploying CAS 5.3.10 on Wildfly 14, using a Maven Overlay as specified in https://apereo.github.io/cas/5.3.x/installation/Configuring-Servlet-Container.html#external and using the project template at: https://github.com/apereo/cas-overlay-template/tree/5.3
I have already edit the pom which deploys correctly on Wildfly 9, but on Wildfly 14 deploy fails with the following exception:
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.core.io.VfsUtils.invokeVfsMethod(VfsUtils.java:100) at org.springframework.core.io.VfsUtils.getFile(VfsUtils.java:172) at org.springframework.core.io.VfsResource.getFile(VfsResource.java:90) at org.apereo.cas.util.CasVersion.getDateTime(CasVersion.java:59) at org.apereo.cas.util.SystemUtils.getSystemInfo(SystemUtils.java:50) ...........
The problem seems to be related to the CasVersion
class that attempts to access via VFS (via spring) to retrieve information related last modification date of the module.
Since @Marco didn't provide his fix, I will. For anyone having the same issue follow below steps to resolve:
cas-overlay-template
, create CasVersion.java
under src/main/java/org/apereo/cas/util
with the following content: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();
}
}
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>
<app-server>-tomcat</app-server>
with <app-server></app-server>
since you gonna provide application server.Above steps should be enough to resolve the reported issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With