<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>

<p>Following <a href="https://stackoverflow.com/a/67526886/11604596">Averi Kitsch's answer</a> and using the same <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java11/springboot-helloworld" rel="nofollow noreferrer">springboot-helloworld</a> example, I was able to get it working locally after updating pom.xml. However, much like it did for you, it only worked when I ran it locally and would fail when I deployed it on Google Cloud. The issue was that the Dockerfile I was using was ignoring all of the jar files in the /target/lib directory, and I needed to copy that directory to the image. Note that I used Google Cloud Run, but I believe this should work for most deployments using Dockerfile.</p>
<p>Here's what I ended up with:</p>
<p><strong>Dockerfile</strong></p>
<pre><code>FROM maven:3.8-jdk-11 as builder

WORKDIR /app
COPY pom.xml .
COPY src ./src

RUN mvn package -DskipTests

FROM adoptopenjdk/openjdk11:alpine-jre

COPY --from=builder /app/target/springboot-helloworld-*.jar /springboot-helloworld.jar

# IMPORTANT! - Copy the library jars to the production image!
COPY --from=builder /app/target/lib /lib

CMD [&quot;java&quot;, &quot;-Djava.security.egd=file:/dev/./urandom&quot;, &quot;-jar&quot;, &quot;/springboot-helloworld.jar&quot;]
</code></pre>
<p><strong>pom.xml</strong></p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.example.appengine&lt;/groupId&gt;
  &lt;artifactId&gt;springboot-helloworld&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;

  &lt;parent&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
    &lt;version&gt;2.5.4&lt;/version&gt;
    &lt;relativePath/&gt;
  &lt;/parent&gt;

  &lt;properties&gt;
    &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;
    &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;
  &lt;/properties&gt;

  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&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.123.8&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;plugins&gt;
      &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;
    &lt;/plugins&gt;
  &lt;/build&gt;

&lt;/project&gt;
</code></pre>
