title: java.nio.file.ProviderNotFoundException: Provider not found
body: <p>I´ve got this exception provider not found, but don´t know how to solve it. Here is my code:</p>
  <pre><code> @Bean
      public FileSystem fileSystem() {
          try {
              Path path = Paths.get(&quot;C:/Users/home/Desktop/mydir&quot;);
              FileSystem ext2fs = FileSystems.newFileSystem(path, Thread.currentThread().getContextClassLoader());
              
              return ext2fs;
          } catch (IOException e) {
              e.printStackTrace();
              return null;
          }
      }
  </code></pre>
  <p>Does anyone know what could be the problem and how to solve it.
  The idea is that i have this bean for filesystem, which i will later use for crud operation, but this bean is because if i later want to change storage that it would be easily just changed in this bean, for example if i want to use google as storage instead of local storage or something like that just set it up in this method. I´m using Spring Boot 2.3.3</p>
  <p><strong>Update - complete exception</strong></p>
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystem' defined in class path resource [Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.nio.file.FileSystem]: Factory method 'fileSystem' threw exception; nested exception is java.nio.file.ProviderNotFoundException: Provider not found
      at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
      at Application.main(Application.java:10) [classes/:na]
  Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.nio.file.FileSystem]: Factory method 'fileSystem' threw exception; nested exception is java.nio.file.ProviderNotFoundException: Provider not found
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      ... 20 common frames omitted
  Caused by: java.nio.file.ProviderNotFoundException: Provider not found
      at java.nio.file.FileSystems.newFileSystem(FileSystems.java:407) ~[na:1.8.0_251]
      at Config.fileSystem(FileSystemConfig.java:23) ~[classes/:na]
      at Config$$EnhancerBySpringCGLIB$$53bc71a0.CGLIB$fileSystem$0(&lt;generated&gt;) ~[classes/:na]
      at Config$$EnhancerBySpringCGLIB$$53bc71a0$$FastClassBySpringCGLIB$$4ee51dad.invoke(&lt;generated&gt;) ~[classes/:na]
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at Config$$EnhancerBySpringCGLIB$$53bc71a0.fileSystem(&lt;generated&gt;) ~[classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_251]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_251]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_251]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_251]
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      ... 21 common frames omitted
  </code></pre>
  <p><strong>New update</strong></p>
  <pre><code>Caused by: java.lang.IllegalArgumentException: Path component should be '/'
      at sun.nio.fs.WindowsFileSystemProvider.checkUri(WindowsFileSystemProvider.java:69) ~[na:1.8.0_251]
      at sun.nio.fs.WindowsFileSystemProvider.getFileSystem(WindowsFileSystemProvider.java:86) ~[na:1.8.0_251]
      at java.nio.file.FileSystems.getFileSystem(FileSystems.java:221) ~[na:1.8.0_251]
      at FileSystemConfig.fileSystem(FileSystemConfig.java:23) ~[classes/:na]
      at FileSystemConfig$$EnhancerBySpringCGLIB$$53bc71a0.CGLIB$fileSystem$0(&lt;generated&gt;) ~[classes/:na]
      at FileSystemConfig$$EnhancerBySpringCGLIB$$53bc71a0$$FastClassBySpringCGLIB$$4ee51dad.invoke(&lt;generated&gt;) ~[classes/:na]
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      at FileSystemConfig$$EnhancerBySpringCGLIB$$53bc71a0.fileSystem(&lt;generated&gt;) ~[classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_251]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_251]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_251]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_251]
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
      ... 21 common frames omitted
  </code></pre>