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

Problems loading classpath resources within QuarkusTestResource classes #17175

Closed
jamesnetherton opened this issue May 12, 2021 · 2 comments · Fixed by #17200
Closed

Problems loading classpath resources within QuarkusTestResource classes #17175

jamesnetherton opened this issue May 12, 2021 · 2 comments · Fixed by #17200
Labels
kind/bug Something isn't working
Milestone

Comments

@jamesnetherton
Copy link
Contributor

Describe the bug

Testing camel-quarkus with Quarkus 2.0.0.Alpha2, I noticed a number of test failures that seem to be related to the loading of classpath resources.

The problems occur where we do some pre-test setup work within a QuarkusTestResourceLifecycleManager impl. If some third party lib attempts to load a resource from the classpath, it appears to be failing.

For example, we use org.apache.ftpserver to set up a local FTP server and pass it a keystore to configure security. The loading of the keystore from the classpath fails. E.g the FTP library does:

getClass().getClassLoader().getResourceAsStream(storeFile.getPath())

Similarly, some tests that use testcontainers also fail where testcontainers tries to load a resource from the classpath.

This was previously working fine in 2.0.0.Alpha1.

Expected behavior

Classpath resource loading works successfully.

Actual behavior

null is returned from getResource / getResourceAsStream etc. E.g in the case of the aforementioned FTP server example

To Reproduce

  1. Clone reproducer project https://github.com/jamesnetherton/quarkus-test-resource-demo.
  2. Run tests to observe the failure. mvn clean test. Note the console message:
Caused by: org.apache.ftpserver.FtpServerConfigurationException: Key store could not be loaded from server.jks
  1. Rerun tests, forcing 2.0.0.Alpha1 and observe success. mvn clean test -Dquarkus.platform.version=2.0.0.Alpha1.
@jamesnetherton jamesnetherton added the kind/bug Something isn't working label May 12, 2021
@gsmet
Copy link
Member

gsmet commented May 12, 2021

/cc @stuartwdouglas

@stuartwdouglas
Copy link
Member

This will work with quarkus.test.flat-class-path=true

The root cause here is a bug in https://github.com/gkopff/mina-ftpserver/blob/master/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java#L297

It uses getClass().getClassLoader() rather than Thread.currentThread().getContextClassLoader().

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue May 13, 2021
This allows non-class resources to be loaded parent first
to work around ClassLoading issues in libraries.

Fixes quarkusio#17175
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue May 13, 2021
This allows non-class resources to be loaded parent first
to work around ClassLoading issues in libraries.

Fixes quarkusio#17175
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants