Today, when using POI to do an Excel export, a null pointer error is always reported. Later, after I carefully searched through the log, I found the real problem;
The error is as follows:
HTTP Status 500 – Request processing failed; nested exception is java.lang.NullPointerException
type Exception report
message Request processing failed; nested exception is java.lang.NullPointerException
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) javax.servlet.http.HttpServlet.service(HttpServlet.java:624) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) com.bool.filter.RequestFilter.doFilterInternal(RequestFilter.java:37) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) com.bool.filter.CorsFilter.doFilter(CorsFilter.java:31)
root cause
java.lang.NullPointerException java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106) com.bool.controller.DetectionController.historyRecordDownkoad(DetectionController.java:264) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) javax.servlet.http.HttpServlet.service(HttpServlet.java:624) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) com.bool.filter.RequestFilter.doFilterInternal(RequestFilter.java:37) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) com.bool.filter.CorsFilter.doFilter(CorsFilter.java:31)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.77 logs.
However, this is not the problem; when I debugged, I found another cause of the error;
java.lang.IllegalArgumentException: The workbook already contains a sheet with this name
The workbook already contains a piece of this name;
Okay, I found the problem.
solution:
Just modify the sheet page name in the export template;
Read More:
- [Solved] Request processing failed; nested exception is java.lang.NullPointerException
- [Solved] swagger3 Error: org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- [Solved] Response Export error on submit request on future invoke, java.lang.OutOfMemoryError: Java heap space
- Request processing failed; nested exception is com.alibaba.fastjson.JSONException: can not cast to J
- NestedServletException, Handler dispatch failed; nested exception is java.lang.StackOverflowError [Solved]
- Tencent cloud container easyexcel export excel error NoClassDefFoundError: could not initialize class sun.awt.x11fontmanager
- [Solved] Springboot Reflection calls ServiceImpl Error: java.lang.NullPointerException, mapper is null
- Springboot integrates redis factory method ‘redisconnectionfactory’ threw exception; nested exception is
- [How to Solve] java.lang.IllegalArgumentException: Request header is too large
- Hive ERROR Failed with exception java.io.IOException:java.lang.IllegalArgumentException
- [Solved] java.lang.reflect.InaccessibleObjectException: Unable to make protected java.net.http.HttpRequest()…
- [Solved] java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/util/ByteArrayBuffer
- [Solved] Error: exception: java.lang.reflect.InvocationTargetException: null
- spark Program Error: ERROR01——java.lang.NullPointerException
- [Solved] Ureport2 export word error: unable to access this website
- com.netflix.zuul.exception.zuulexception Timeout (Fixed)
- [Solved] Non-fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library “libmmkv.so“ not found
- Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: [How to Solve]
- How to Solve Spring MVC upload file error
- Error reported when springboot connects to redis nested exception is redis.clients.jedis . exceptions.JedisConnectionException