码迷,mamicode.com
首页 > 编程语言 > 详细

成功解决 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException:报错

时间:2020-09-04 17:02:33      阅读:52      评论:0      收藏:0      [点我收藏+]

标签:service   tomcat   mvc   socket   src   websocket   get   Once   apach   

相信小伙伴们一定遇到过这种错误,

  1 八月 26, 2020 11:32:32 上午 org.apache.catalina.core.StandardWrapperValve invoke
  2 严重: Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter ‘pageindex‘ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.] with root cause
  3 java.lang.IllegalStateException: Optional int parameter ‘pageindex‘ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
  4     at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleNullValue(AbstractNamedValueMethodArgumentResolver.java:245)
  5     at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:116)
  6     at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
  7     at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167)
  8     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
  9     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
 10     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
 11     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
 12     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
 13     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
 14     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
 15     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
 16     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
 17     at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
 18     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
 19     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
 20     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
 21     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 22     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 23     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 24     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 25     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
 26     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 27     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 28     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 29     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
 30     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
 31     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
 32     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
 33     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
 34     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
 35     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 36     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
 37     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
 38     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
 39     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
 40     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
 41     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 42     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 43     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 44     at java.lang.Thread.run(Thread.java:745)
 45 
 46 八月 26, 2020 11:36:20 上午 org.apache.catalina.core.ApplicationContext log
 47 信息: Destroying Spring FrameworkServlet ‘springmvc‘
 48 八月 26, 2020 11:36:21 上午 org.apache.catalina.core.ApplicationContext log
 49 信息: No Spring WebApplicationInitializer types detected on classpath
 50 八月 26, 2020 11:36:30 上午 org.apache.catalina.core.ApplicationContext log
 51 信息: Initializing Spring DispatcherServlet ‘springmvc‘
 52 八月 26, 2020 11:36:38 上午 org.apache.catalina.core.StandardWrapperValve invoke
 53 严重: Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
 54 java.lang.NullPointerException
 55     at com.bdqn.controller.UserController.touserlist(UserController.java:66)
 56     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 57     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 58     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 59     at java.lang.reflect.Method.invoke(Method.java:498)
 60     at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
 61     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
 62     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
 63     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
 64     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
 65     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
 66     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
 67     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
 68     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
 69     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
 70     at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
 71     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
 72     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
 73     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
 74     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 75     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 76     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 77     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 78     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
 79     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 80     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 81     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 82     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
 83     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
 84     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
 85     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
 86     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
 87     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
 88     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 89     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
 90     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
 91     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
 92     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
 93     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
 94     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 95     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 96     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 97     at java.lang.Thread.run(Thread.java:745)
 98 
 99 八月 26, 2020 11:38:13 上午 org.apache.catalina.core.ApplicationContext log
100 信息: Destroying Spring FrameworkServlet ‘springmvc‘
101 八月 26, 2020 11:38:14 上午 org.apache.catalina.core.ApplicationContext log
102 信息: No Spring WebApplicationInitializer types detected on classpath
103 八月 26, 2020 11:38:45 上午 org.apache.catalina.core.ApplicationContext log
104 信息: No Spring WebApplicationInitializer types detected on classpath
105 八月 26, 2020 11:38:47 上午 org.apache.catalina.core.ApplicationContext log
106 信息: Initializing Spring DispatcherServlet ‘springmvc‘
107 八月 26, 2020 11:38:48 上午 org.apache.catalina.core.StandardWrapperValve invoke
108 严重: Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter ‘pageindex‘ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.] with root cause
109 java.lang.IllegalStateException: Optional int parameter ‘pageindex‘ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
110     at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleNullValue(AbstractNamedValueMethodArgumentResolver.java:245)
111     at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:116)
112     at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
113     at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167)
114     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
115     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
116     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
117     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
118     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
119     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
120     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
121     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
122     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
123     at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
124     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
125     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
126     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
127     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
128     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
129     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
130     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
131     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
132     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
133     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
134     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
135     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
136     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
137     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
138     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
139     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
140     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
141     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
142     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
143     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
144     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
145     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
146     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
147     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
148     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
149     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
150     at java.lang.Thread.run(Thread.java:745)

 

下面就与大家分享错误报告以及解决方法把

认真分析 ,就能捕捉到关键错误 

parameter ‘pageindex‘

代表controller方法中的参数出现错误
所以小伙伴们可以仔细检查最开始进方法的时候,参数是否为空 以及参数名是否一致,还有是否允许必填
如图就是我更改后的

技术图片

required表示是否必填,多用于方法最开始进入防止出现空指针
到最后我们还是发现还是报错,
最后我们可以仔细看到,pageindex 类型为int 该原类型是不支持为空 所以改成 Integer即可解决

成功解决 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException:报错

标签:service   tomcat   mvc   socket   src   websocket   get   Once   apach   

原文地址:https://www.cnblogs.com/sunlang369/p/13564237.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!