Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger-ui.html returns 404 when large resource files are present - webjars-locator issue #11

Open
AnthonyNicholas opened this issue Aug 16, 2021 · 0 comments

Comments

@AnthonyNicholas
Copy link

Describe the bug

  • SpringDoc swagger-ui.html returns 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.

(Note: I opened this issue with the springdoc team. They said this is actually a bug in webjars-locator - see discussion here: springdoc/springdoc-openapi#1249)

The logs show:

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.

Expected behavior

  • Should see the swagger-ui page load showing book service resources.

Additional context
One of our APIs requires the use of large binary resource files. Springdoc is working aok for all the others. It is only failing where these large files are involved. I am able to replicate the issue in your own demo environment as detailed above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant