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

Missing resource for Testcontainers #554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wyhasany
Copy link

@wyhasany wyhasany commented Oct 29, 2024

What does this PR do?

Testcontainers uses ResourceReaper.class as a resource. When I run testcontainers with GraalVM I get following exception:

Caused by: java.lang.IllegalArgumentException: Resource with path 
org/testcontainers/utility/ResourceReaper.class 
could not be found on any of these classloaders: 
[jdk.internal.loader.ClassLoaders$AppClassLoader@2f7c7260]
  org.testcontainers.utility.MountableFile.getClasspathResource(MountableFile.java:158)
  org.testcontainers.utility.MountableFile.forClasspathResource(MountableFile.java:103)
  org.testcontainers.utility.MountableFile.forClasspathResource(MountableFile.java:72)
  org.testcontainers.DockerClientFactory.checkMountableFile(DockerClientFactory.java:274)
  org.testcontainers.DockerClientFactory.isFileMountingSupported(DockerClientFactory.java:97)
  [...]

Code sections where the PR accesses files, network, docker or some external service

It starts here:
https://github.com/testcontainers/testcontainers-java/blob/main/core/src/main/java/org/testcontainers/DockerClientFactory.java#L288

Checklist before merging

Testcontainers uses `ResourceReaper.class` as a resource. When I run testcontainers with GraalVM I get following exception:
```
Caused by: java.lang.IllegalArgumentException: Resource with path 
org/testcontainers/utility/ResourceReaper.class 
could not be found on any of these classloaders: 
[jdk.internal.loader.ClassLoaders$AppClassLoader@2f7c7260]
  org.testcontainers.utility.MountableFile.getClasspathResource(MountableFile.java:158)
  org.testcontainers.utility.MountableFile.forClasspathResource(MountableFile.java:103)
  org.testcontainers.utility.MountableFile.forClasspathResource(MountableFile.java:72)
  org.testcontainers.DockerClientFactory.checkMountableFile(DockerClientFactory.java:274)
  org.testcontainers.DockerClientFactory.isFileMountingSupported(DockerClientFactory.java:97)
  [...]
```

It starts here:
https://github.com/testcontainers/testcontainers-java/blob/main/core/src/main/java/org/testcontainers/DockerClientFactory.java#L288
@wyhasany wyhasany requested a review from a team as a code owner October 29, 2024 11:50
@Kehrlann
Copy link
Contributor

Kehrlann commented Nov 5, 2024

Hey @wyhasany !

I've been working in this area a bit. A few questions:

  1. Which version of Testcontainers are you using?
  2. Would you mind sharing the test that fails? We could add it to the test file.
  3. Have you verified that adding this entry in the reflection metadata fixes your test? It is possible that you get more failures when adding this.

The reason I think this may not be enough is that the check leverages this:

        MountableFile mountableFile = MountableFile.forClasspathResource(
            ResourceReaper.class.getName().replace(".", "/") + ".class"
        );

And this is going to bring a few filesystem-related issues. See the discussions here: testcontainers/testcontainers-java#7954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants