When the Plugin is executed on a Java 9+ JVM a ClassCastException is thrown:
[ERROR] Could not add schema location to classpath
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 com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.getSchemaLocation (SpringMvcEndpointGeneratorMojo.java:477)
at com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.generateEndpoints (SpringMvcEndpointGeneratorMojo.java:261)
at com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.execute (SpringMvcEndpointGeneratorMojo.java:521)
[...]
The Plugin currently adds the Schema Location to the Classpath by getting the SystemClassLoader as an URLClassLoader, but because the underlying SystemClassLoader is no longer a URLClassLoader this results in an Error:
|
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); |
|
Class<?> urlClass = URLClassLoader.class; |
|
Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class }); |
|
method.setAccessible(true); |
|
method.invoke(urlClassLoader, new Object[] { new File(resolvedPath).toURI().toURL() }); |
|
return "classpath:/"; // since we have added this folder to |
|
// the classpath this |
|
// should be used by the plugin |
Several threads about this issue describe a workaround by further specifying the Class#forName usage, but as far as I understand this is not feasible for the current impl where it is assumed that the default classloader knowns the schema files.
When the Plugin is executed on a Java 9+ JVM a ClassCastException is thrown:
The Plugin currently adds the Schema Location to the Classpath by getting the SystemClassLoader as an URLClassLoader, but because the underlying SystemClassLoader is no longer a URLClassLoader this results in an Error:
springmvc-raml-plugin/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/SpringMvcEndpointGeneratorMojo.java
Lines 492 to 499 in 6387072
Several threads about this issue describe a workaround by further specifying the
Class#forNameusage, but as far as I understand this is not feasible for the current impl where it is assumed that the default classloader knowns the schema files.