[Latest] Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception (10 methods)

tags: Spring MVC

When I was working on Spring related projects, I was stuck with this bug for a long time. I found a lot of other people’s blogs on the Internet, and several browsers were opened... I was looking for help from the team leader when I was unable to find it. Assigned a null initial value such as:

List<TermAllRes> termAllResList = null;

Should be changed to:

List<TermAllRes> termAllResList = new ArrayList<TermAllRes>();

Of course, everyone’s bugs are different. Below I will give some examples of common solutions. There should be a solution:

  1. The reason for the error is generally that when the service is introduced into the controller, you forgot to write the annotation @Resource or @ Autowired.
  2. Introduce spring-boot-starter-actuator in POM:
 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-actuator</artifactId>
 </dependency>

Note: This package is used for health monitoring.
ps: In fact, the official documentation is also pitted. It may have been developed from the beginning to the present. Some omissions in the documentation have caused some packages to be introduced and not cleared, and even the official sample code is not explained. The above problem appears

  1. Possible reason: compilation error
    Solution:
    mvn clean
    mvn package

  2. Wrong words for page related attributes

  3. Temporarily turn off the search engine server ElasticSearch

  4. The service layer implementation class does not add the annotation @Autowired.
    The function of @Autowired is to automatically inject dependent beans.
    Modification method:
    add comment

  5. Delete all the antlr folders in the path .m2\repository\

    Then re-use Maven update project

  6. Serialization exception
    Solution: serialize pojo

  7. The exception is caused by the conflict between response.getOutputStream() and response.getWriter(), or the last used information has not been cleared, so the cache needs to be reset.
    Solution: add response.resetBuffer(); before use

    Critical: Servlet.service() for servlet dispatcherServlet threw exception
    java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at org.apache.catalina.connector.Response.getWriter(Response.java:610)
    at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)

  8. In a Controller, new but not a Controller is ok; then call a service and an error is reported

    Finally, change the new object to injection

ps: When working on a project, we will always encounter bugs. We should face it calmly. Every time we solve a bug, we have a sense of accomplishment! This is the precipitation of knowledge!

Learning is like rowing upstream

Intelligent Recommendation

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler d

problem: solution: Change the path in .m2\repository\antlr Delete all folders Then re-use Mavenupdate project...

Error: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.StringUtil...

java error: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception

Do todayspring-mvcThere was an error, showing that it could not be foundspringUnder the frameutilPackagedStringUtilsTools inmatchesCharactermethod. Error display wrong reason Check the code and there ...

Successfully resolved servlet.Service () for servlet [dispatcherservlet] in Context with path [] threw exception [Requ

Look at the access path is not a "/" Then you have to do it is to eliminate the comments used by SpringBoot. You can refer to this big blog: If you can't solve it, then if you see if your HT...

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circular

2021-05-25 13:08:29.219 ERROR 17508 — [nio-8081-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circula...

More Recommendation

Question: servlet.service () for servlet [dispatcherservlet] in Context with path [] threw exception [Reques

Question: Servlet.service () for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Er...

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Filtered

First report error Here, Jedis error is displayed, and it is a Java and Redis connection error. There are several problems here: My redis is installed on the server, so the Host's port address should ...

SpringBoot-Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

In this error, I have an error in Mapper.xml in the data connection: Above the code<resultMap id="???">Id value needs and below<resultmap="???">One-to-one...

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Could not

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Could not resolve view with name 'employee/login' in servlet with name 'dispatcherServlet'] with root cause R...

Servlet.service () for service [dispatcherServlet] in context with path [] Threw Exception

1. Error Process: Report an error after deleting a picture resource during the project test: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processi...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top