openlvc / disco

Java library for Distributed Interactive Simulation
11 stars 3 forks source link

Starting Disco in HLA mode with Java 21 causes exception #66

Open timpokorny opened 5 months ago

timpokorny commented 5 months ago

Summary

Reported by @jarrodgreene -

Tried to start in HLA mode, but it immediately dies due to a ClassCastException inside Disco. Stack trace below. Basically, the extendClasspath() function gets called to try and add RTI stuff onto the classpath, but it relies on the ClassLoader.getSystemClassLoader() being a URLClassLoader to do so. This is no longer the case post Java 8 - so this fails. Simply removing this call causes the RTI (Portico in this case) not to function.

ERROR [AWT-EventQueue-0]: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
java.io.IOException: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
...
...
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
    at org.openlvc.disco.utils.ClassLoaderUtils.extendClasspath(ClassLoaderUtils.java:65) ~[disco.jar:?]
    at org.openlvc.disco.OpsCenter.applyRprClasspathHack(OpsCenter.java:185) ~[disco.jar:?]
    at org.openlvc.disco.OpsCenter.open(OpsCenter.java:108) ~[disco.jar:?]
    at org.openlvc.disco.application.DisApplication.start(DisApplication.java:117) ~[disco.jar:?]
        ...
    ... 38 more