EmbeddedMongo on /tmp directory has not execution permission
See original GitHub issueHi I’ve an issue with mongo embedded. I’ve fedora 32 SO with kernel “Linux fedora-desktop 5.11.22-100.fc32.x86” set up this dependency on maven:
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>3.4.8</version>
<scope>test</scope>
</dependency>`
And this is my test code:
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoDatabase;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.MongodConfig;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
import java.io.IOException;
public class EmbMongotest {
public static void main(String[] args) throws IOException {
MongodStarter starter = MongodStarter.getDefaultInstance();
int port = Network.getFreeServerPort();
MongodConfig mongodConfig = MongodConfig.builder()
.version(Version.Main.PRODUCTION)
.net(new Net(port, Network.localhostIsIPv6()))
.build();
MongodExecutable mongodExecutable = null;
try {
mongodExecutable = starter.prepare(mongodConfig);
MongodProcess mongod = mongodExecutable.start();
try (MongoClient mongo = MongoClients.create("mongodb://localhost:"+port)) {
SimpleMongoClientDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(mongo,"testDB");
MongoDatabase db = mongo.getDatabase("testDB");
MongoTemplate template = new MongoTemplate(factory);
template.save(new TClass("variable"));
} catch (Exception exception) {
exception.printStackTrace();
}
} finally {
if (mongodExecutable != null)
mongodExecutable.stop();
}
}
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
static class TClass {
private String testVar;
}
}
This is the issue that I encountered:
2022-09-12 09:48:16 fedora-desktop ERROR AbstractProcess:116 - failed to call start()
java.io.IOException: Cannot run program "/tmp/extract-35fba5ae-5537-4e2a-8505-cf700f548460extractmongod": error=13, Permesso negato
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at de.flapdoodle.embed.process.runtime.ProcessControl.start(ProcessControl.java:165)
at de.flapdoodle.embed.process.runtime.AbstractProcess.<init>(AbstractProcess.java:96)
at de.flapdoodle.embed.mongo.AbstractMongoProcess.<init>(AbstractMongoProcess.java:53)
at de.flapdoodle.embed.mongo.MongodProcess.<init>(MongodProcess.java:50)
at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:44)
at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:34)
at de.flapdoodle.embed.process.runtime.Executable.start(Executable.java:109)
at com.fw.EmbMongotest.main(EmbMongotest.java:39)
Caused by: java.io.IOException: error=13, Permesso negato
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 9 common frames omitted
I have tried to set system properties flapdoodle directory to another dir with all permission but it not works too. Only if I launch the java application with root permission I can run this code without errors.
I have had this error since 1 month ago. Before the mongoembedded worked great.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:16 (10 by maintainers)
Top Results From Across the Web
Why does my flapdoodle Embedded MongoDB test fail to run ...
mongo library uses BitSize class to determine the OS architecture. In my system System.getProperty("os.arch") was not returning a value listed ...
Read more >"Permission denied" during installation from mounted /tmp ...
On Linux and UNIX operating systems, if the temporary directory (default: /tmp) is a mounted drive, all users must be able to directly...
Read more >Permission denied in /tmp - Unix & Linux Stack Exchange
To anyone having the same problem in the future, /tmp is a sticky folder by default, meaning only the file owner can modify...
Read more >Integration testing done right with Embedded MongoDB
Embedding an in-memory database is fast and each JVM can run its own isolated database. But we no longer test against the actual...
Read more >Unable to write to /tmp directory in macOS ... - Super User
^This^ is why the accepted answer works, and this solution is much safer! No need to nuke existing directories then recreate them with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@filirnd with the latest release i extract all binaries to some directory in home folder and checking the hash of the content to ensure that the right version is used … so /tmp is not used for that anymore.
Thank you. However, is not a problem, now embedded mongo works great. Seems it uses the home folder now for temporary files. I’m going to close the issue. Thank you for your support.