Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to download embedded MongoDB, behind proxy, using automatic configuration script

I have a Spring Boot project, built using Maven, where I intend to use embedded mongo db. I am using Eclipse on Windows 7.

I am behind a proxy that uses automatic configuration script, as I have observed in the Connection tab of Internet Options. I am getting the following exception when I try to run the application.

java.io.IOException: Could not open inputStream for https://downloads.mongodb.org/win32/mongodb-win32-i386-3.2.2.zip at de.flapdoodle.embed.process.store.Downloader.downloadInputStream(Downloader.java:131) ~[de.flapdoodle.embed.process-2.0.1.jar:na] at de.flapdoodle.embed.process.store.Downloader.download(Downloader.java:69) ~[de.flapdoodle.embed.process-2.0.1.jar:na] ....

MongoDB gets downloaded just fine, when I hit the following URL in my web browser:

https://downloads.mongodb.org/win32/mongodb-win32-i386-3.2.2.zip

This leads me to believe that probably I'm missing some configuration in my Eclipse or may be the maven project itself. Please help me to find the right configuration.

like image 393
de_xtr Avatar asked May 29 '18 08:05

de_xtr


3 Answers

What worked for me on a windows machine:

Download the zip file (https://downloads.mongodb.org/win32/mongodb-win32-i386-3.2.2.zip) manually and put it (not unpack) into this folder:

C:\Users\<Username>\.embedmongo\win32\
like image 103
d2k2 Avatar answered Sep 18 '22 11:09

d2k2


Indeed the problem is about your proxy (a corporate one I guess).

If the proxy do not require authentication, you can solve your problem easily just by adding the appropriate -Dhttp.proxyHost=... and -Dhttp.proxyPort=... (or/and the same with "https.[...]") as JVM arguments in your eclipse junit Runner, as suggested here : https://github.com/learning-spring-boot/learning-spring-boot-2nd-edition-code/issues/2

like image 39
Michael Zilbermann Avatar answered Sep 17 '22 11:09

Michael Zilbermann


One solution to your problem is to do the following.

  1. Download MongoDB and place it on a ftp server which is inside your corporate network (for which you would not need proxy).

  2. Then write a configuration in your project like this

    @Bean
    @ConditionalOnProperty("mongo.proxy")
    public IRuntimeConfig embeddedMongoRuntimeConfig() {
        final Command command = Command.MongoD;
        final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaults(command)
            .artifactStore(new ExtractedArtifactStoreBuilder()
                .defaults(command)
                .download(new DownloadConfigBuilder()
                    .defaultsForCommand(command)
                    .downloadPath("your-ftp-path")
                    .build())
                .build())
            .build();
        return runtimeConfig;
    }
    

With the property mongo.proxy you can control whether Spring Boot downloads MongoDB from your ftp server or from outside. If it is set to true then it downloads from the ftp server. If not then it tries to download from the internet.

like image 21
pvpkiran Avatar answered Sep 20 '22 11:09

pvpkiran