Why is SpringDoc swagger-ui.html returning 404 / Whitelabel Error Page when large resource files are present (eg 7 files of ~380Mb each)? This is occuring after building and running the JAR file. The endpoint works fine when the project is run directly from Intellij.

I have been able to replicate the bug using the SpringDoc demo repository. The expected behaviour when going to /swagger-ui.html is for the swagger-ui page to load showing book service resources. However when large resource files are present instead I am getting a 404 with the logs showing:

19:30:49.012 [http-nio-8080-exec-2] INFO  o.s.web.servlet.DispatcherServlet - Completed initialization in 14 ms
19:30:49.023 [http-nio-8080-exec-2] TRACE o.s.web.servlet.DispatcherServlet - GET "/swagger-ui.html", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
19:30:49.026 [http-nio-8080-exec-2] TRACE o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to org.springdoc.webmvc.ui.SwaggerWelcomeWebMvc#redirectToUi(HttpServletRequest)
19:30:49.036 [http-nio-8080-exec-2] TRACE o.s.web.method.HandlerMethod - Arguments: [org.apache.catalina.connector.RequestFacade@5e68b13]
19:30:49.064 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.m.a.HttpEntityMethodProcessor - Using 'application/json;q=0.8', given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8] and supported [application/json, application/*+json, application/json, application/*+json]
19:30:49.064 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.m.a.HttpEntityMethodProcessor - Nothing to write: null body
19:30:49.065 [http-nio-8080-exec-2] TRACE o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Applying default cacheSeconds=-1
19:30:49.065 [http-nio-8080-exec-2] TRACE o.s.web.servlet.DispatcherServlet - No view rendering, null ModelAndView returned.
19:30:49.065 [http-nio-8080-exec-2] DEBUG o.s.web.servlet.DispatcherServlet - Completed 302 FOUND, headers={masked}
19:30:49.071 [http-nio-8080-exec-3] TRACE o.s.web.servlet.DispatcherServlet - GET "/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config", parameters={masked}, headers={masked} in DispatcherServlet 'dispatcherServlet'
19:30:49.073 [http-nio-8080-exec-3] TRACE o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns [/swagger-ui*/**, /**]
19:30:49.073 [http-nio-8080-exec-3] TRACE o.s.w.s.h.SimpleUrlHandlerMapping - Mapped to HandlerExecutionChain with [ResourceHttpRequestHandler [Classpath [META-INF/resources/webjars/]]] and 3 interceptors
19:30:49.074 [http-nio-8080-exec-3] DEBUG o.s.w.s.r.ResourceHttpRequestHandler - Resource not found
19:30:49.074 [http-nio-8080-exec-3] TRACE o.s.web.servlet.DispatcherServlet - No view rendering, null ModelAndView returned.
19:30:49.074 [http-nio-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND, headers={masked}

To Reproduce

  1. Clone https://github.com/springdoc/springdoc-openapi-demos
  2. Create 7 large resource files: head -c 400000000 /dev/urandom > BigTestFile1.bin head -c 400000000 /dev/urandom > BigTestFile2.bin head -c 400000000 /dev/urandom > BigTestFile3.bin head -c 400000000 /dev/urandom > BigTestFile4.bin head -c 400000000 /dev/urandom > BigTestFile5.bin head -c 400000000 /dev/urandom > BigTestFile6.bin head -c 400000000 /dev/urandom > BigTestFile7.bin
  3. Create a folder called LargeFiles in springdoc-openapi-book-service src/main/java/resources and place all 7 TestFiles in that folder.
  4. Build the jar mvn clean package
  5. Run the jar java -jar ./target/springdoc-openapi-book-service-3.1.6-SNAPSHOT.jar
  6. Navigate to http:/0.0.0.0:8080/swagger-ui.html.

I have been working on a number of APIs - this issue seems to only be occur when large resource files are present & only after building/running the JAR file.

0

There are 0 answers