org.springframework.http.InvalidMediaTypeException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • If a client is sending a POST message with an empty/invalid header 'Content-Type' the request fails with [InvalidMediaTypeException|https://github.com/spring-projects/spring-framework/blob/v4.2.6.RELEASE/spring-web/src/main/java/org/springframework/http/InvalidMediaTypeException.java]. {code}org.springframework.http.InvalidMediaTypeException: Invalid mime type "null": does not contain '/' at org.springframework.http.MediaType.parseMediaType(MediaType.java:385) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:722) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.http.server.ServletServerHttpRequest.getHeaders(ServletServerHttpRequest.java:116) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:810) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:71) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:954) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) [spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870) [spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] {code} I think that [org.springframework.http.HttpHeaders#getContentType|https://github.com/spring-projects/spring-framework/blob/v4.2.6.RELEASE/spring-web/src/main/java/org/springframework/http/HttpHeaders.java#L720-L723] should handle InvalidMediaTypeException exception and return null in such cases or you should change behaviour of [org.springframework.http.MediaType#parseMediaType|https://github.com/spring-projects/spring-framework/blob/v4.2.6.RELEASE/spring-web/src/main/java/org/springframework/http/MediaType.java#L379-L393]
    via by Nazar Vishka,
  • If a client is sending a POST message with an empty/invalid header 'Content-Type' the request fails with [InvalidMediaTypeException|https://github.com/spring-projects/spring-framework/blob/v4.2.6.RELEASE/spring-web/src/main/java/org/springframework/http/InvalidMediaTypeException.java]. {code}org.springframework.http.InvalidMediaTypeException: Invalid mime type "null": does not contain '/' at org.springframework.http.MediaType.parseMediaType(MediaType.java:385) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:722) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.http.server.ServletServerHttpRequest.getHeaders(ServletServerHttpRequest.java:116) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:810) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:71) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:954) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) [spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870) [spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] {code} I think that [org.springframework.http.HttpHeaders#getContentType|https://github.com/spring-projects/spring-framework/blob/v4.2.6.RELEASE/spring-web/src/main/java/org/springframework/http/HttpHeaders.java#L720-L723] should handle InvalidMediaTypeException exception and return null in such cases or you should change behaviour of [org.springframework.http.MediaType#parseMediaType|https://github.com/spring-projects/spring-framework/blob/v4.2.6.RELEASE/spring-web/src/main/java/org/springframework/http/MediaType.java#L379-L393]
    via by Nazar Vishka,
    • org.springframework.http.InvalidMediaTypeException: Invalid mime type "null": does not contain '/' at org.springframework.http.MediaType.parseMediaType(MediaType.java:385)[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:722)[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.http.server.ServletServerHttpRequest.getHeaders(ServletServerHttpRequest.java:116)[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:810)[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:71)[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503)[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:954)[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)[spring-webmvc-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    johnxflyjohnxfly
    2 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    qavidqavid
    1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,