title: Spring boot - Unsupported config data location 'optional:file:./config/*/'
body: <p>We are migrating a spring boot application from 2.2.4 to 2.4.3
  <br> The application can be run with inbuilt tomcat / Tomcat war deployment.
  <br> <strong>Environment</strong>: Windows Azul Java 11 (Zulu 11) and Tomcat 9.0.33</p>
  <p>If I run the code with my Netbeans linked tomcat, it works fine.
  <br/>If I deploy the generated war directly in the same standalone tomcat, it throws the following error.</p>
  <pre><code>SEVERE [main] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [D:\apache-tomcat-9.0.33-without port - rest.war]
          java.lang.IllegalStateException: Error starting child
  ................................................................
  ................................................................
  Caused by: org.springframework.boot.context.config.UnsupportedConfigDataLocationException: Unsupported config data location 'optional:file:./config/*/'
                  at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:110)
  
  </code></pre>
  <p>On reading through the Spring document, it was mentioned that By default, Spring Boot includes config/*/ in the default search locations. Ref: <a href="https://docs.spring.io/spring-boot/docs/2.4.0-SNAPSHOT/reference/htmlsingle/#boot-features-external-config-files-wildcards" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/2.4.0-SNAPSHOT/reference/htmlsingle/#boot-features-external-config-files-wildcards</a></p>
  <p><br> I further debugged with spring boot source and spring core source and identified that there is a mismatch in the classloader that happens that was the cause of this exception.</p>
  <p>SpringFactoriesLoader is the class that gets loaded by <strong>ParallelWebAppClassLoader</strong> in NB linked tomcat and by <strong>URLClassLoader</strong> in standalone tomcat.
  <br>Ref: Line No 129 at <a href="https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java#L129" rel="nofollow noreferrer">https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java#L129</a></p>
  <p>The cache at Line 136 has the config classes loaded by ParallelWebAppClassLoader, but not by the URLlassLoader. So the 2 resolvers - ConfigTreeConfigDataLocationResolver, StandardConfigDataLocationResolver in boot v2.4.3 are not getting identified when it tries to retrieve with the key URLlassLoader (Line 136).</p>
  <p>Not sure whether this is an issue with Springboot / SpringCore / Tomcat / any new configuration to be added as a part of our upgrade.
  <br> Note: Our application.properties has spring.servlet.multipart related properties only.</p>