Skip to content

Conversation

@stewue
Copy link
Contributor

@stewue stewue commented Nov 14, 2025

Hi

I found an issue in the spring boot 4.0.0-RC2.

There is a FileNotFoundException with the message class path resource [org/springframework/boot/web/server/mime-mappings.properties] cannot be opened because it does not exist if a static file is requested via url.

Stack trace
jakarta.servlet.ServletException: Request processing failed: java.lang.IllegalArgumentException: Unable to load the default MIME types
	at [email protected]/org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:892) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-11.0.13.jar:6.1]
	at [email protected]/org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:874) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:710) ~[tomcat-embed-core-11.0.13.jar:6.1]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:128) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-7.0.0-RC3.jar:7.0.0-RC3]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-7.0.0-RC3.jar:7.0.0-RC3]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:107) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-7.0.0-RC3.jar:7.0.0-RC3]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:107) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-7.0.0-RC3.jar:7.0.0-RC3]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:107) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:513) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:335) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:262) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:375) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:206) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:149) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:83) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:72) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:397) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:903) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1778) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:946) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:480) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:57) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at java.base/java.lang.Thread.run(Thread.java:1474) ~[na:na]
Caused by: java.lang.IllegalArgumentException: Unable to load the default MIME types
	at [email protected]/org.springframework.boot.web.server.MimeMappings$DefaultMimeMappings.load(MimeMappings.java:341) ~[spring-boot-web-server-4.0.0-RC2.jar:na]
	at [email protected]/org.springframework.boot.web.server.MimeMappings$DefaultMimeMappings.get(MimeMappings.java:309) ~[spring-boot-web-server-4.0.0-RC2.jar:na]
	at [email protected]/org.springframework.boot.web.server.MimeMappings$LazyMimeMappingsCopy.get(MimeMappings.java:381) ~[spring-boot-web-server-4.0.0-RC2.jar:na]
	at org.springframework.boot.tomcat.TomcatEmbeddedContext.findMimeMapping(TomcatEmbeddedContext.java:152) ~[spring-boot-tomcat-4.0.0-RC2.jar:4.0.0-RC2]
	at org.apache.catalina.core.ApplicationContext.getMimeType(ApplicationContext.java:317) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at org.apache.catalina.core.ApplicationContextFacade.getMimeType(ApplicationContextFacade.java:96) ~[tomcat-embed-core-11.0.13.jar:11.0.13]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.resolveMediaType(AbstractMessageConverterMethodProcessor.java:555) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.safeExtension(AbstractMessageConverterMethodProcessor.java:549) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.addContentDispositionHeader(AbstractMessageConverterMethodProcessor.java:524) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:339) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:261) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.ResponseEntityReturnValueHandler.handleReturnValue(ResponseEntityReturnValueHandler.java:80) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:78) ~[spring-web-7.0.0-RC3.jar:7.0.0-RC3]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:135) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:934) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:853) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:86) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:866) ~[spring-webmvc-7.0.0-RC3.jar:na]
	at [email protected]/org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1003) ~[spring-webmvc-7.0.0-RC3.jar:na]
	... 30 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/web/server/mime-mappings.properties] cannot be opened because it does not exist
	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:212) ~[spring-core-7.0.0-RC3.jar:7.0.0-RC3]
	at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:135) ~[spring-core-7.0.0-RC3.jar:7.0.0-RC3]
	at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:124) ~[spring-core-7.0.0-RC3.jar:7.0.0-RC3]
	at [email protected]/org.springframework.boot.web.server.MimeMappings$DefaultMimeMappings.load(MimeMappings.java:331) ~[spring-boot-web-server-4.0.0-RC2.jar:na]
	... 49 common frames omitted

I created a demo project to reproduce the bug https://github.com/stewue/spring-boot-4-mime-mappings

During testing I discovered that the exception is only thrown if requires spring.boot.web.server is in the module-info.java of my project (without spring-boot-web-server is part of the unnamed module and the property file can still be access).

In bb80db8 the web server auto-configure classes were moved into spring-boot-web-server module, but the mime-mappings.properties was still in the spring-boot module.

To fix this issue I also move the property file to the new created module spring-boot-web-server. I have not seen any dependencies other than MimeMappings.java to this property file. However, someone with more knowledge should verify this.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 14, 2025
- there is a `FileNotFoundException` with the message `class path resource [org/springframework/boot/web/server/mime-mappings.properties] cannot be opened because it does not exist` if a static file is requested via url
- with spring boot 4.0.0 the modularization of the project was changed. in bb80db8 the web server auto-configure classes were moved into spring-boot-web-server module
- the `mime-mappings.properties` was still in the spring-boot module
- without java modules this is not an issue as spring-boot-web-server is part of the unnamed module and the property file can still be access
- however if a `requires spring.boot.web.server` is added the exception was thrown
- to fix this issue also move the property file to the new created module spring-boot-web-server

Signed-off-by: Stefan Würsten <[email protected]>
@snicoll snicoll added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 14, 2025
@snicoll snicoll added this to the 4.0.0 milestone Nov 14, 2025
@snicoll snicoll self-assigned this Nov 14, 2025
@snicoll snicoll changed the title move mime-mappings.properties to correct module org/springframework/boot/web/server/mime-mappings.properties should be located in spring-boot-web-server Nov 14, 2025
snicoll pushed a commit that referenced this pull request Nov 14, 2025
This commit moves mime-mapping.properties in the module that actually
uses it, rather than in the top-level spring-boot module.

See gh-48138

Signed-off-by: Stefan Würsten <[email protected]>
@snicoll snicoll closed this in 50ee576 Nov 14, 2025
@snicoll
Copy link
Member

snicoll commented Nov 14, 2025

Good catch, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants