testcontainers / testcontainers/testcontainers-java

Exception NoClassDefFoundError org/testcontainers/utility/PathUtils

Open
#1,454 34 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/bug
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Hello

There is an exception in MountableFile, it does not find the class PathUtils when it calls recursiveDeleteDir from shutdownHook.
I think this is because during the shutdown hook the class loader is already closed by Maven and cannot be used to load new classes.

See attached stack trace

Exception in thread "Thread-17" java.lang.NoClassDefFoundError: org/testcontainers/utility/PathUtils$1
	at org.testcontainers.utility.PathUtils.recursiveDeleteDir(PathUtils.java:26)
	at org.testcontainers.utility.MountableFile.lambda$deleteOnExit$0(MountableFile.java:284)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: org.testcontainers.utility.PathUtils$1
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 3 more

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MountableFile.deleteOnExit and PathUtils.recursiveDeleteDir, the entry points shown in the stack trace. Reproduce the shutdown-hook failure under Maven and inspect whether class loading occurs after the loader closes. Done means cleanup completes without the NoClassDefFoundError and the relevant behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.