<p>i've found two similar posts here but one hasn't been answered and the other was about android. I have a spring boot project and I want to access GCP Storage files within my application.</p>
<p>Locally everything works fine I can access my bucket and read as well as store files in my storage. But when i upload it to gcp kubernetes I get the following exception:</p>
<blockquote>
<p>&quot;java.nio.file.FileSystemNotFoundException: Provider &quot;gs&quot; not
installed     at java.nio.file.Paths.get(Paths.java:147) ~[na:1.8.0_212]
at
xx.xx.StorageService.saveFile(StorageService.java:64)
~[classes!/:0.3.20-SNAPSHOT]</p>
</blockquote>
<p>My line of code where it appears is like follows:</p>
<pre><code>public void saveFile(MultipartFile multipartFile, String path) {
    String completePath = filesBasePath + path;
    
    Path filePath = Paths.get(URI.create(completePath)); // &lt;- exception appears here
    Files.createDirectories(filePath);
    multipartFile.transferTo(filePath);
        
}
</code></pre>
<p>}</p>
<p>The completePath could result in something like &quot;gs://my-storage/path/to/file/image.jpg&quot;</p>
<p>I have the following dependencies:</p>
<pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-gcp-starter-storage&lt;/artifactId&gt;
    &lt;version&gt;1.2.6.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;google-cloud-nio&lt;/artifactId&gt;
    &lt;version&gt;0.122.5&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
<p>Does anyone have a clue where to look at?
The only real difference except for the infrastructure is that i don't explicitly don't use authentication on kubernetes as it is not required according to the documentation</p>
<blockquote>
<p>When using Google Cloud libraries from a Google Cloud Platform
environment such as Compute Engine, Kubernetes Engine, or App Engine,
no additional authentication steps are necessary.</p>
</blockquote>

tagtraeumer
<p>It looks like the conventional Spring boot packaging here isn't packaging the dependency in the needed way. Usually you'll see something like:</p>
<pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;2.4.5&lt;/version&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;goals&gt;
                &lt;goal&gt;repackage&lt;/goal&gt;
            &lt;/goals&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
&lt;/plugin&gt;
</code></pre>
<p>However, for the &quot;gs&quot; provider to be accessible it needs to be in the 'lib/' folder. You can package it manually by copying the dependencies and then creating the JAR (this is based on the <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java11/springboot-helloworld" rel="nofollow noreferrer">springboot-helloworld</a> sample:</p>
<pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
      &lt;execution&gt;
          &lt;id&gt;copy-dependencies&lt;/id&gt;
          &lt;phase&gt;prepare-package&lt;/phase&gt;
          &lt;goals&gt;
              &lt;goal&gt;copy-dependencies&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;configuration&gt;
              &lt;outputDirectory&gt;
                  ${project.build.directory}/lib
              &lt;/outputDirectory&gt;
          &lt;/configuration&gt;
      &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
    &lt;archive&gt;
        &lt;manifest&gt;
            &lt;addClasspath&gt;true&lt;/addClasspath&gt;
            &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
            &lt;mainClass&gt;
              com.example.appengine.springboot.SpringbootApplication
            &lt;/mainClass&gt;
        &lt;/manifest&gt;
    &lt;/archive&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
</code></pre>
<p>Originally <a href="https://github.com/googleapis/java-storage-nio/issues/547" rel="nofollow noreferrer">posted on GitHub</a>.</p>
