Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent First ClassLoader issue with JimFS #17512

Closed
aaronanderson opened this issue May 28, 2021 · 0 comments · Fixed by #17518
Closed

Parent First ClassLoader issue with JimFS #17512

aaronanderson opened this issue May 28, 2021 · 0 comments · Fixed by #17518
Labels
area/core kind/bug Something isn't working
Milestone

Comments

@aaronanderson
Copy link

Describe the bug

I am attempting to use the JimFS in-memory Java NIO FileSystem provider in my Quarkus application and I am encountering a classloader issue. Given the nature of JimFS it needs to load in the System Classload and I utilized the quarkus.class-loading.parent-first-artifacts configuration to identify it as needing to be loaded in the base classloader. While this setting works fine for JUnit tests it does not work in fast-jar mode when running Quarkus in dev mode and production mode. It is my understanding that this was supposed to be fixed in #17391

Expected behavior

The JimFS jar will be loaded in the application classloader instead of the runtime classloader in all run modes (dev/test/prod).

Actual behavior

An exception is generated due to JimFS not being loaded in the correct classloader and the registration of a custom URL failing.

2021-05-27 22:59:18,833 ERROR [FileManager] (Quarkus Main Thread) Loaded from ClassLoader QuarkusClassLoader:Quarkus Base Runtime ClassLoader: DEV
2021-05-27 22:59:18,838 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.net.MalformedURLException: unknown protocol: jimfs
	at java.base/java.net.URL.<init>(URL.java:679)
	at java.base/java.net.URL.fromURI(URL.java:746)
	at java.base/java.net.URI.toURL(URI.java:1139)
	at quarkus.imfs.reproducer.FileManager.onStart(FileManager.java:27)
...

To Reproduce

Here is a link to the reproducer: quarkus-jimfs

Steps to reproduce the behavior:

  1. Change directories to the reproducer
  2. run mvn clean install . The project will successfully build and the test will successfully run with JimFS loaded in the correct base classloader.
  3. run mvn clean install quarkus:dev The application will fail to start due to JimFS being loaded in the incorrect runtime classloader.
  4. run java -jar target/quarkus-app/quarkus-run.jar The same classloader issue will occur.

Configuration

quarkus.class-loading.parent-first-artifacts=com.google.jimfs

Output of java -version

 java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment Corretto-16.0.1.9.1 (build 16.0.1+9)
OpenJDK 64-Bit Server VM Corretto-16.0.1.9.1 (build 16.0.1+9, mixed mode, sharing)

I tested with JDK 11 as well and the same error occured.

Quarkus Version

2.0.0.CR2

@aaronanderson aaronanderson added the kind/bug Something isn't working label May 28, 2021
geoand added a commit to geoand/quarkus that referenced this issue May 28, 2021
aloubyansky added a commit that referenced this issue May 31, 2021
Use proper parent first artifacts Set in fast-jar
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone May 31, 2021
@gsmet gsmet modified the milestones: 2.1 - main, 2.0.0.Final May 31, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants