1. Explore
  2. »
  3. Spring Web MVC

Spring Web MVC errors

Model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale and theme resolution as well as support for uploading files

https://github.com/spring-projects/spring-framework
Solution coverage:
Summary coverage:

Top patterns

  1. Request processing failed; NestedServletException
    • You will get this exception when your controller, service or component class directly instanciates any object (i.e new Object();), so there's no dependency injection happening, which is why the repository isn't wired and NPE is thrown.
    • Use @Autowired annotation OR @Autowired with @Qualifier
      @Autowired
      @Qualifier("object1")`
      

    Example:

    Service class:
    @Resource(name = "singleTransactionsService")
    private SingleTransactionsService singleTransactionsService;
    
    Controller class:
    @Service("singleTransactionsService")
    
  2. Neither BindingResult nor plain target object for bean name
    • By default the model attribute name is taken as Bean class's name with first lowercase letter.
    • In the controller, you need to add the bean object as an attribute of the model:
    • Let's see the example,
    @RequestMapping(value = "/", method = RequestMethod.GET) 
    public String myMethod(Model model) { 
        model.addAttribute("bean", new Bean()); 
        return "bean"; 
    }
    
    • Add this line into your controller : model.addAttribute("bean", new Bean());
    • By doing this the form which expects a backing object naming "bean" will be made available to it.
  3. Could not resolve view with name
    • There can be many different scenarios where you can get this exception, try below solution.
      • Use @ResponseBody annotation before your method.
      • Update grails version at last 3.2.6
      • Make sure that grails-app/views/hello/index.gsp file exists.

    Example:

    @RequestMapping(value = "/index", method = RequestMethod.POST)
    @ResponseBody
    public void sampleMethod(@RequestBody MyRequestBean reqBean, HttpServletRequest request) {
        ...
    }
    
    • Spring treats @RequestMapping methods with void return type in the following manner

    • void : if the method handles the response itself (by writing the response content directly, declaring an argument of type ServletResponse / HttpServletResponse for that purpose) or if the view name is supposed to be implicitly determined through a RequestToViewNameTranslator.

    • Therefore since there is no HttpServletResponse parameter to this method, Spring assumes that you would like the view name to be determined through a RequestToViewNameTranslator.

    • If you do not specify a particular RequestToViewNameTranslator to use in your context, then the default implementation kicks in which will: simply transforms the URI of the incoming request into a view name.

    If you don't want the URI of the incoming request to be used as the view name, you have a few options:

    • Configure a custom RequestToViewNameTranslator with the behavior you would like
    • Add a HttpServletResponse parameter to this method if you would like to write to the response directly rather than View resolution take place.
    • Change the return type of this method to String, View, or ModelAndView to be able to specify the view or view name within the method.
Error patternsPackagesClassesMethodsExceptions
DescriptionException TypeEntry MethodWeb pages

Request processing failed; NestedServletException

org.springframework.web.util.NestedServletException
org.springframework.web.servlet.FrameworkServlet.processRequest
142Web pages
1Solution
NestedServletExceptionFrameworkServlet.processRequest()142

Neither BindingResult nor plain target object for bean name

java.lang.IllegalStateException
org.springframework.web.servlet.support.BindStatus.<init>
113Web pages
1Solution
IllegalStateExceptionBindStatus.<init>()113

Could not resolve view with name

javax.servlet.ServletException
org.springframework.web.servlet.DispatcherServlet.render
110Web pages
1Solution
ServletExceptionDispatcherServlet.render()110

Neither BindingResult nor plain target object for bean name

java.lang.IllegalStateException
1 frames hidden
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus
76Web pages
1Solution
IllegalStateExceptionAbstractDataBoundFormElementTag.getBindStatus()76

Could not resolve view with name '/xxx' in servlet with name 'xxx'; ServletException

javax.servlet.ServletException
4 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
73Web pages
1Solution
ServletExceptionFrameworkServlet.processRequest()73

Unable to process incoming GET Request

org.springframework.web.util.NestedServletException
1 frames hidden
org.springframework.web.servlet.FrameworkServlet.doGet
59Web pages
1Solution
NestedServletExceptionFrameworkServlet.doGet()59

Error creating bean with name, Injection of autowired dependencies failed

org.springframework.beans.factory.BeanCreationException
11 frames hidden
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext
39Web pages
1Solution
BeanCreationExceptionFrameworkServlet.configureAndRefreshWebApplicationContext()39

Could not find acceptable representation

org.springframework.web.HttpMediaTypeNotAcceptableException
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters
37Web pages
1Solution
HttpMediaTypeNotAcceptableExceptionAbstractMessageConverterMethodProcessor.writeWithMessageConverters()37

Neither BindingResult nor plain target object for bean name; IllegalStateException

java.lang.IllegalStateException
6 frames hidden
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes
36Web pages
1Solution
IllegalStateExceptionAbstractDataBoundFormElementTag.writeDefaultAttributes()36

FrameworkServlet.service() has thrown a NestedServletException

org.springframework.web.util.NestedServletException
3 frames hidden
org.springframework.web.servlet.FrameworkServlet.service
35Web pages
NestedServletExceptionFrameworkServlet.service()35

A ServletContext is required to configure default servlet handling; IllegalArgumentException

java.lang.IllegalArgumentException
1 frames hidden
org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>
32Web pages
1Solution
IllegalArgumentExceptionDefaultServletHandlerConfigurer.<init>()32

A ServletContext is required to configure default servlet handling

java.lang.IllegalArgumentException
2 frames hidden
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping
31Web pages
1Solution
IllegalArgumentExceptionWebMvcConfigurationSupport.defaultServletHandlerMapping()31

FrameworkServlet.configureAndRefreshWebApplicationContext() has thrown a BeanCreationException

org.springframework.beans.factory.NoSuchBeanDefinitionException
18 frames hidden
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext
31Web pages
BeanCreationExceptionFrameworkServlet.configureAndRefreshWebApplicationContext()31

FrameworkServlet.service() has thrown a NestedServletException

org.springframework.web.util.NestedServletException
3 frames hidden
org.springframework.web.servlet.FrameworkServlet.service
30Web pages
NestedServletExceptionFrameworkServlet.service()30

FrameworkServlet.processRequest() has thrown a NestedServletException

org.springframework.web.util.NestedServletException
2 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
28Web pages
NestedServletExceptionFrameworkServlet.processRequest()28

RequestContextAwareTag.doStartTag() has thrown an IllegalStateException

java.lang.IllegalStateException
10 frames hidden
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag
25Web pages
IllegalStateExceptionRequestContextAwareTag.doStartTag()25

FrameworkServlet.doPost() has thrown an InternalErrorException

org.apache.kylin.rest.exception.InternalErrorException
15 frames hidden
org.springframework.web.servlet.FrameworkServlet.doPost
25Web pages
InternalErrorExceptionFrameworkServlet.doPost()25

DispatcherServlet.getHandlerAdapter() has thrown a ServletException

javax.servlet.ServletException
org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter
24Web pages
ServletExceptionDispatcherServlet.getHandlerAdapter()24

AbstractDataBoundFormElementTag.getBindStatus() has thrown an IllegalStateException

java.lang.IllegalStateException
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus
23Web pages
IllegalStateExceptionAbstractDataBoundFormElementTag.getBindStatus()23

AbstractDataBoundFormElementTag.getPropertyPath() has thrown an IllegalStateException

java.lang.IllegalStateException
1 frames hidden
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath
22Web pages
IllegalStateExceptionAbstractDataBoundFormElementTag.getPropertyPath()22

FrameworkServlet.doGet() has thrown a ServletException

javax.servlet.ServletException
8 frames hidden
org.springframework.web.servlet.FrameworkServlet.doGet
22Web pages
ServletExceptionFrameworkServlet.doGet()22

AbstractHandlerMapping.getHandler() has thrown a HttpRequestMethodNotSupportedException

org.springframework.web.HttpRequestMethodNotSupportedException
4 frames hidden
org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler
21Web pages
HttpRequestMethodNotSupportedExceptionAbstractHandlerMapping.getHandler()21

FrameworkServlet.processRequest() has thrown a ServletException

javax.servlet.ServletException
3 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
20Web pages
ServletExceptionFrameworkServlet.processRequest()20

FrameworkServlet.processRequest() has thrown a TemplateInputException

org.thymeleaf.exceptions.TemplateInputException
10 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
20Web pages
TemplateInputExceptionFrameworkServlet.processRequest()20

FrameworkServlet.configureAndRefreshWebApplicationContext() has thrown a NoSuchBeanDefinitionException

org.springframework.beans.factory.NoSuchBeanDefinitionException
16 frames hidden
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext
20Web pages
NoSuchBeanDefinitionExceptionFrameworkServlet.configureAndRefreshWebApplicationContext()20

DispatcherServlet.getHandler() has thrown a HttpRequestMethodNotSupportedException

org.springframework.web.HttpRequestMethodNotSupportedException
5 frames hidden
org.springframework.web.servlet.DispatcherServlet.getHandler
19Web pages
HttpRequestMethodNotSupportedExceptionDispatcherServlet.getHandler()19

FrameworkServlet.processRequest() has thrown a RuntimeException

java.lang.NullPointerException
7 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
18Web pages
RuntimeExceptionFrameworkServlet.processRequest()18

Controller does not support the RequestMethod

org.springframework.web.HttpRequestMethodNotSupportedException
8 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
18Web pages
1Solution
HttpRequestMethodNotSupportedExceptionFrameworkServlet.processRequest()18

AbstractHandlerMethodMapping.initHandlerMethods() has thrown an IllegalStateException

java.lang.IllegalStateException
2 frames hidden
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods
18Web pages
IllegalStateExceptionAbstractHandlerMethodMapping.initHandlerMethods()18

DispatcherServlet.doDispatch() has thrown a HttpRequestMethodNotSupportedException

org.springframework.web.HttpRequestMethodNotSupportedException
6 frames hidden
org.springframework.web.servlet.DispatcherServlet.doDispatch
18Web pages
HttpRequestMethodNotSupportedExceptionDispatcherServlet.doDispatch()18

ServletInvocableHandlerMethod.invokeAndHandle() has thrown a BeanInstantiationException

org.springframework.beans.BeanInstantiationException
7 frames hidden
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle
18Web pages
BeanInstantiationExceptionServletInvocableHandlerMethod.invokeAndHandle()18

DispatcherServlet.triggerAfterCompletionWithError() has thrown a NestedServletException

org.springframework.web.util.NestedServletException
org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError
17Web pages
NestedServletExceptionDispatcherServlet.triggerAfterCompletionWithError()17

FrameworkServlet.configureAndRefreshWebApplicationContext() has thrown a BeanCreationException

org.springframework.beans.factory.BeanCreationException
10 frames hidden
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext
17Web pages
BeanCreationExceptionFrameworkServlet.configureAndRefreshWebApplicationContext()17

AbstractHandlerMethodMapping.afterPropertiesSet() has thrown an IllegalStateException

java.lang.IllegalStateException
3 frames hidden
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet
17Web pages
IllegalStateExceptionAbstractHandlerMethodMapping.afterPropertiesSet()17

ServletInvocableHandlerMethod.invokeAndHandle() has thrown a MissingServletRequestParameterException

org.springframework.web.bind.MissingServletRequestParameterException
5 frames hidden
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle
16Web pages
MissingServletRequestParameterExceptionServletInvocableHandlerMethod.invokeAndHandle()16

DispatcherServlet.doDispatch() has thrown a NestedServletException

org.springframework.web.util.NestedServletException
1 frames hidden
org.springframework.web.servlet.DispatcherServlet.doDispatch
15Web pages
NestedServletExceptionDispatcherServlet.doDispatch()15

FrameworkServlet.processRequest() has thrown a ServletException

javax.servlet.ServletException
3 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
15Web pages
ServletExceptionFrameworkServlet.processRequest()15

AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters() has thrown a HttpMediaTypeNotSupportedException

org.springframework.web.HttpMediaTypeNotSupportedException
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters
15Web pages
HttpMediaTypeNotSupportedExceptionAbstractMessageConverterMethodArgumentResolver.readWithMessageConverters()15

RequestContextAwareTag.doStartTag() has thrown an IllegalStateException

java.lang.IllegalStateException
8 frames hidden
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag
15Web pages
IllegalStateExceptionRequestContextAwareTag.doStartTag()15

FrameworkServlet.doGet() has thrown a ServletException

javax.servlet.ServletException
4 frames hidden
org.springframework.web.servlet.FrameworkServlet.doGet
15Web pages
ServletExceptionFrameworkServlet.doGet()15

FrameworkServlet.processRequest() has thrown an IllegalStateException

java.lang.IllegalStateException
15 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
14Web pages
IllegalStateExceptionFrameworkServlet.processRequest()14

AbstractHandlerMethodMapping.registerHandlerMethod() has thrown an IllegalStateException

java.lang.IllegalStateException
2 frames hidden
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod
14Web pages
IllegalStateExceptionAbstractHandlerMethodMapping.registerHandlerMethod()14

JspAwareRequestContext.initContext() has thrown an IllegalStateException

java.lang.IllegalStateException
3 frames hidden
org.springframework.web.servlet.support.JspAwareRequestContext.initContext
14Web pages
IllegalStateExceptionJspAwareRequestContext.initContext()14

ServletInvocableHandlerMethod.invokeAndHandle() has thrown a HttpMediaTypeNotAcceptableException

org.springframework.web.HttpMediaTypeNotAcceptableException
4 frames hidden
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle
13Web pages
HttpMediaTypeNotAcceptableExceptionServletInvocableHandlerMethod.invokeAndHandle()13

FrameworkServlet.processRequest() has thrown a BeanInstantiationException

org.springframework.beans.BeanInstantiationException
13 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
13Web pages
BeanInstantiationExceptionFrameworkServlet.processRequest()13

FrameworkServlet.processRequest() has thrown a NestedServletException

org.springframework.web.util.NestedServletException
3 frames hidden
org.springframework.web.servlet.FrameworkServlet.processRequest
13Web pages
NestedServletExceptionFrameworkServlet.processRequest()13

HttpServletBean.init() has thrown a BeanCreationException

org.springframework.beans.factory.BeanCreationException
15 frames hidden
org.springframework.web.servlet.HttpServletBean.init
13Web pages
BeanCreationExceptionHttpServletBean.init()13

ServletInvocableHandlerMethod.invokeAndHandle() has thrown a BindException

org.springframework.validation.BindException
4 frames hidden
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle
13Web pages
BindExceptionServletInvocableHandlerMethod.invokeAndHandle()13

JstlUtils.exposeLocalizationContext() has thrown a NoClassDefFoundError

java.lang.NoClassDefFoundError
org.springframework.web.servlet.support.JstlUtils.exposeLocalizationContext
12Web pages
NoClassDefFoundErrorJstlUtils.exposeLocalizationContext()12

ServletInvocableHandlerMethod.invokeAndHandle() has thrown a HttpMediaTypeNotAcceptableException

org.springframework.web.HttpMediaTypeNotAcceptableException
3 frames hidden
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle
12Web pages
HttpMediaTypeNotAcceptableExceptionServletInvocableHandlerMethod.invokeAndHandle()12
Nothing to list here.
Nothing to list here.
Nothing to list here.
Nothing to list here.