org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/'

Spring JIRA | Hendy Irawan | 5 months ago
  1. 0

    The stacktrace given if we have erroneous {{@RequestMapping}}, e.g. {{@RequestMapping(consumes="text_plain")}} is currently less useful. It should mention the class and method where the error occured, so the developer can easily fix it. Sample error below. {noformat} 10:53:07.200 WARN | | | | host-startStop-1 | ationConfigWebApplicationContext | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/' 10:53:07.790 ERROR | | | | host-startStop-1 | o.s.w.c.ContextLoader | Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/' at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:538) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/' at org.springframework.http.MediaType.parseMediaType(MediaType.java:385) at org.springframework.web.servlet.mvc.condition.AbstractMediaTypeExpression.<init>(AbstractMediaTypeExpression.java:53) at org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition$ConsumeMediaTypeExpression.<init>(ConsumesRequestCondition.java:210) at org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition.parseExpressions(ConsumesRequestCondition.java:97) at org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition.<init>(ConsumesRequestCondition.java:71) at org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder.build(RequestMappingInfo.java:507) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:258) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:206) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:185) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:53) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$1.inspect(AbstractHandlerMethodMapping.java:233) at org.springframework.core.MethodIntrospector$1.doWith(MethodIntrospector.java:72) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:530) at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:68) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:229) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:213) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:183) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:125) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ... 22 common frames omitted Caused by: org.springframework.util.InvalidMimeTypeException: Invalid mime type "text_plain": does not contain '/' at org.springframework.util.MimeTypeUtils.parseMimeType(MimeTypeUtils.java:231) at org.springframework.http.MediaType.parseMediaType(MediaType.java:382) ... 41 common frames omitted Jul 11, 2016 11:23:07 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/' at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:538) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/' at org.springframework.http.MediaType.parseMediaType(MediaType.java:385) at org.springframework.web.servlet.mvc.condition.AbstractMediaTypeExpression.<init>(AbstractMediaTypeExpression.java:53) at org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition$ConsumeMediaTypeExpression.<init>(ConsumesRequestCondition.java:210) at org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition.parseExpressions(ConsumesRequestCondition.java:97) at org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition.<init>(ConsumesRequestCondition.java:71) at org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder.build(RequestMappingInfo.java:507) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:258) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:206) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:185) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:53) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$1.inspect(AbstractHandlerMethodMapping.java:233) at org.springframework.core.MethodIntrospector$1.doWith(MethodIntrospector.java:72) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:530) at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:68) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:229) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:213) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:183) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:125) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ... 22 more Caused by: org.springframework.util.InvalidMimeTypeException: Invalid mime type "text_plain": does not contain '/' at org.springframework.util.MimeTypeUtils.parseMimeType(MimeTypeUtils.java:231) at org.springframework.http.MediaType.parseMediaType(MediaType.java:382) ... 41 more {noformat} Related to SPR-9142.

    Spring JIRA | 5 months ago | Hendy Irawan
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is org.springframework.http.InvalidMediaTypeException: Invalid mime type "text_plain": does not contain '/'
  2. 0

    Zuul not passing the Content-Type to the service

    Stack Overflow | 9 months ago | Grinish
    org.springframework.util.InvalidMimeTypeException: Invalid mime type "as": does not contain '/'
  3. 0

    GitHub comment 2#97588093

    GitHub | 2 years ago | mwkrieger
    org.springframework.util.InvalidMimeTypeException: Invalid mime type "json": does not contain '/'
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    additional checks when fetching Github zipballs?

    GitHub | 3 years ago | bclozel
    org.springframework.util.InvalidMimeTypeException: Invalid mime type "appmaker-8b2fad993ca3e7993cb5edab03c01e9a01c8537e": does not contain '/'
  6. 0

    Spring: How to avoid InvalidMimeTypeException in WFS request ("text/xml; subtype=gml/2.1.2")

    Stack Overflow | 1 year ago | Hannes Smit
    org.springframework.util.InvalidMimeTypeException: Invalid mime type "text/xml; subtype=gml/2.1.2": Invalid token character '/' in token "gml/2.1.2"

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.util.InvalidMimeTypeException

      Invalid mime type "text_plain": does not contain '/'

      at org.springframework.util.MimeTypeUtils.parseMimeType()
    2. Spring Core
      MimeTypeUtils.parseMimeType
      1. org.springframework.util.MimeTypeUtils.parseMimeType(MimeTypeUtils.java:231)
      1 frame
    3. Spring
      MediaType.parseMediaType
      1. org.springframework.http.MediaType.parseMediaType(MediaType.java:382)
      1 frame
    4. Spring MVC
      AbstractHandlerMethodMapping$1.inspect
      1. org.springframework.web.servlet.mvc.condition.AbstractMediaTypeExpression.<init>(AbstractMediaTypeExpression.java:53)
      2. org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition$ConsumeMediaTypeExpression.<init>(ConsumesRequestCondition.java:210)
      3. org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition.parseExpressions(ConsumesRequestCondition.java:97)
      4. org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition.<init>(ConsumesRequestCondition.java:71)
      5. org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder.build(RequestMappingInfo.java:507)
      6. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:258)
      7. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.createRequestMappingInfo(RequestMappingHandlerMapping.java:206)
      8. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:185)
      9. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getMappingForMethod(RequestMappingHandlerMapping.java:53)
      10. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$1.inspect(AbstractHandlerMethodMapping.java:233)
      10 frames
    5. Spring Core
      MethodIntrospector.selectMethods
      1. org.springframework.core.MethodIntrospector$1.doWith(MethodIntrospector.java:72)
      2. org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:530)
      3. org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:68)
      3 frames
    6. Spring MVC
      RequestMappingHandlerMapping.afterPropertiesSet
      1. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:229)
      2. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:213)
      3. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:183)
      4. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:125)
      4 frames
    7. Spring Beans
      DefaultListableBeanFactory.preInstantiateSingletons
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
      3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
      4. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
      5. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
      6. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      7. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
      8. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
      9. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
      9 frames
    8. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
      2. org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:538)
      3. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)
      3 frames
    9. Spring
      ContextLoaderListener.contextInitialized
      1. org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
      2. org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
      3. org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      3 frames
    10. Glassfish Core
      ContainerBase$StartChild.call
      1. org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
      2. org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
      3. org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      4. org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      5. org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      5 frames
    11. Java RT
      Thread.run
      1. java.util.concurrent.FutureTask.run(FutureTask.java:266)
      2. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      3. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      4. java.lang.Thread.run(Thread.java:745)
      4 frames