首页

解"java.util.NoSuchElementException: No value present"不存在值错误异常提示

标签:NoSuchElementException     发布时间:2023-02-10   

一、异常说明

解决“java.util.NoSuchElementException: No value present”不存在该元素异常错误异常(不存在值),详细日志>>

java.util.NoSuchElementException: No value present@b@	at java.util.Optional.get(Optional.java:135)@b@	at com.xwood.mds.cloud.sysuser.UserProcesssUnit.getUserData(UserProcesssUnit.java:116)@b@	at com.xwood.mds.cloud.sysuser.UserProcesssUnit.userProcessHandle(UserProcesssUnit.java:204)@b@	at com.xwood.mds.cloud.sysuser.UserProcesssUnit.execute(UserProcesssUnit.java:109)@b@	at com.xwood.mds.cloud.sysuser.UserProcesssUnit$$FastClassBySpringCGLIB$$5cdd02d5.invoke(<generated>)@b@	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)@b@	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)@b@	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)@b@	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)@b@	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)@b@	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)@b@	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)@b@	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)@b@	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)@b@	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)@b@	at com.xwood.mds.cloud.sysuser.UserProcesssUnit$$EnhancerBySpringCGLIB$$a69d688f.execute(<generated>)@b@	at com.xwood.mds.cloud.SysUser.sdk.util.AdapterCallUtil.callCommonAdapter(AdapterCallUtil.java:20)@b@	at com.xwood.mds.cloud.SysUser.sdk.config.DefaultProcessConfig$1.eventFireCall(DefaultProcessConfig.java:28)@b@	at com.xwood.mds.cloud.SysUser.sdk.controller.SysUserClientController.createUser(SysUserClientController.java:38)@b@	at sun.reflect.GeneratedMethodAccessor1224.invoke(Unknown Source)@b@	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)@b@	at java.lang.reflect.Method.invoke(Method.java:498)@b@	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)@b@	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)@b@	at com.xwood.mds.cloud.common.core.tangram.enditpoint.TangramInvocableHandlerMethod.invokeAndHandle(TangramInvocableHandlerMethod.java:79)@b@	at com.xwood.mds.cloud.common.core.tangram.enditpoint.TangramMethodHandlerAdapter.invokeHandlerMethod(TangramMethodHandlerAdapter.java:829)@b@	at com.xwood.mds.cloud.common.core.tangram.enditpoint.TangramMethodHandlerAdapter.handleInternal(TangramMethodHandlerAdapter.java:743)@b@	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)@b@	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)@b@	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)@b@	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)@b@	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)@b@	at javax.servlet.http.HttpServlet.service(HttpServlet.java:665)@b@	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)@b@	at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)@b@	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)@b@	at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327)@b@	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)@b@	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)@b@	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at com.xwood.mds.cloud.common.core.security.component.AfsUserInfoInjectFilter.doFilterInternal(AfsUserInfoInjectFilter.java:65)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter.doFilterInternal(BearerTokenAuthenticationFilter.java:129)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)@b@	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)@b@	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110)@b@	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336)@b@	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211)@b@	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)@b@	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)@b@	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)@b@	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at com.xwood.mds.cloud.common.core.holder.RequestHeaderFilter.doFilter(RequestHeaderFilter.java:72)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at com.xwood.mds.cloud.common.core.security.filter.IgnoreUriFilter.doFilter(IgnoreUriFilter.java:48)@b@	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)@b@	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)@b@	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)@b@	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)@b@	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)@b@	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)@b@	at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)@b@	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117)@b@	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)@b@	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)@b@	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)@b@	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)@b@	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)@b@	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)@b@	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)@b@	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)@b@	at io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52)@b@	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)@b@	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)@b@	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)@b@	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)@b@	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)@b@	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)@b@	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)@b@	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)@b@	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)@b@	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)@b@	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)@b@	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:841)@b@	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)@b@	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019)@b@	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558)@b@	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449)@b@	at java.lang.Thread.run(Thread.java:748)

二、解决方法

从用户查询集合匹配等级01的第一条数据,代码如下 - 因等级字段错写为getUserAccountType()需改为getGrade()

return sysUserList.stream().filter(u -> StringUtils.equals(u.getUserAccountType(), "01")).findFirst().get();

改为 

return sysUserList.stream().filter(u -> StringUtils.equals(u.getGrade(), "01")).findFirst().get();

 

@b@
<<热门下载>>