question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoSuchFileException because path duplicates directory path

See original GitHub issue

Seeing behavior similar to https://github.com/flapdoodle-oss/de.flapdoodle.embed.process/issues/122 during our build process in OpenShift 3.7 on both RHEL7 and RHEL8 base images.

https://catalog.redhat.com/software/containers/redhat-openjdk-18/openjdk18-openshift/58ada5701fbe981673cd6b10?container-tabs=overview

The behavior does not occur during local development on OS X 12.x and 13.0.

We’re using de.flapdoodle.embed.process as part of de.flapdoodle.embed.mongo

We have just migrated our application to Spring Boot 2.7.5 which uses de.flapdoodle.embed.mongo:3.4.11 and de.flapdoodle.embed.process:3.1.15

I’ve included the relevant portion of the stack trace below

Caused by:
--
  | org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.flapdoodle.embed.mongo.MongodExecutable]: Factory method 'embeddedMongoServer' threw exception; nested exception is de.flapdoodle.embed.process.exceptions.DistributionException: java.nio.file.NoSuchFileException: ?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/extractmongod
  | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
  | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
  | ... 138 more
  |  
  | Caused by:
  | de.flapdoodle.embed.process.exceptions.DistributionException: java.nio.file.NoSuchFileException: ?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/extractmongod
  | at de.flapdoodle.embed.process.runtime.Starter.prepare(Starter.java:71)
  | at de.flapdoodle.embed.process.runtime.Starter.prepare(Starter.java:52)
  | at de.flapdoodle.embed.mongo.spring.autoconfigure.EmbeddedMongoAutoConfiguration.embeddedMongoServer(EmbeddedMongoAutoConfiguration.java:104)
  | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  | at java.lang.reflect.Method.invoke(Method.java:498)
  | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
  | ... 139 more
  |  
  | Caused by:
  | java.nio.file.NoSuchFileException: ?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/extractmongod
  | at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
  | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
  | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
  | at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:526)
  | at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
  | at java.nio.file.Files.copy(Files.java:1274)
  | at de.flapdoodle.embed.process.extract.ExtractedFileSets.copy(ExtractedFileSets.java:57)
  | at de.flapdoodle.embed.process.store.ExtractedArtifactStore.extractFileSet(ExtractedArtifactStore.java:110)
  | at de.flapdoodle.embed.process.runtime.Starter.prepare(Starter.java:59)
  | ... 146 more

This only occurs in one test execution (the first) and subsequent test executions start / use the embedded mongo database appropriately. We can see all the other tests pass and the logs for the database shutting down

2022-11-21 18:32:42.407  INFO [,,] 246 --- [      Thread-59] d.f.e.m.s.autoconfigure.EmbeddedMongo    : 2022-11-21T18:32:42.407+0000 I  NETWORK  [conn2] end connection 127.0.0.1:35626 (1 connection now open)

Similar to flapdoodle-oss/de.flapdoodle.embed.process#122 , this appears to be because the path duplicates the target artifact directory ?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22 twice (as ?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/?/.embedmongo/extracted/Linux-B64--redhat_8---4.2.22/extractmongod).

I’ve exhausted most of my resources trying to resolve this, including using de.flapdoodle.embed.mongo.spring and trying to set artifactStorePath using DownloadConfigBuilderCustomizer (which “works” but doesn’t change the behavior)

Working on further reproducibility, and I’ve checked other similar issues and haven’t found a working solution.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
brenthaertleincommented, Dec 9, 2022

Awesome! Glad I could help

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - ConcurrentExecution Exception & nio.file ...
Because, the path variable is shared across all threads and is ... NoSuchFileException happens when you cannot act on the file, like DELETE....
Read more >
$PATH duplication issues - Unix & Linux Stack Exchange
I don't know which other file is setting your $PATH but the duplicated entries are /opt/X11/bin /usr/bin /usr/local/bin /usr/sbin.
Read more >
Duplicate folder name in file path - Visual Studio Feedback
TempFileCollection() and return the basepath as a string. The path erroneously has the last part of the path duplicated. *We have not replicated...
Read more >
Path | Android Developers
Path. bookmark_border. Stay organized with collections Save and categorize content based on your preferences. Dismiss ... Direction dir) ... Direction dir).
Read more >
Find Duplicate File in System - LeetCode
Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found