CUBA REST: Nullpointer exception when returncount is true

Hi,
We are not able to return count when we search an entity sine there is a nullpointer exception when return count is set to true.
Here is the error message:

13:15:53.515 ERROR k.c.t.m.r.T.MilikiExceptionHandler - Exception in REST controller

1/27/2022 4:15:53 PM java.lang.NullPointerException: null

1/27/2022 4:15:53 PM at java.base/java.util.HashMap.putMapEntries(HashMap.java:496) ~[na:na]

1/27/2022 4:15:53 PM at java.base/java.util.HashMap.putAll(HashMap.java:780) ~[na:na]

1/27/2022 4:15:53 PM at com.haulmont.cuba.core.global.LoadContext$Query.setParameters(LoadContext.java:440) ~[classes/:na]

1/27/2022 4:15:53 PM at com.haulmont.addon.restapi.api.service.EntitiesControllerManager.searchEntities(EntitiesControllerManager.java:210) ~[classes/:na]

1/27/2022 4:15:53 PM at com.haulmont.addon.restapi.api.controllers.EntitiesController.searchEntitiesListGet(EntitiesController.java:85) ~[classes/:na]

1/27/2022 4:15:53 PM at jdk.internal.reflect.GeneratedMethodAccessor402.invoke(Unknown Source) ~[na:na]

1/27/2022 4:15:53 PM at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]

1/27/2022 4:15:53 PM at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]

1/27/2022 4:15:53 PM at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[shared/:na]

1/27/2022 4:15:53 PM at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[shared/:na]

1/27/2022 4:15:53 PM at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1427) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[shared/:na]

1/27/2022 4:15:53 PM at com.haulmont.addon.restapi.api.auth.CubaRestLastSecurityFilter.doFilter(CubaRestLastSecurityFilter.java:90) ~[classes/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at com.haulmont.addon.restapi.api.auth.CubaAnonymousAuthenticationFilter.doFilter(CubaAnonymousAuthenticationFilter.java:142) ~[classes/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113) ~[shared/:na]

1/27/2022 4:15:53 PM at com.haulmont.addon.restapi.api.sys.RestExceptionLoggingFilter.doFilter(RestExceptionLoggingFilter.java:42) ~[classes/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[shared/:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108) ~[shared/:na]

1/27/2022 4:15:53 PM at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74) ~[shared/:na]

1/27/2022 4:15:53 PM at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93) ~[classes/:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:228) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:572) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1612) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1582) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773) ~[app.jar:na]

1/27/2022 4:15:53 PM at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905) ~[app.jar:na]

1/27/2022 4:15:53 PM at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

Kindly assist.

Hi,
Can you show your REST request text?

Hi,
Here is ther request payload (it was a GET request).
Endpoint: /app/rest/v2/entities/miliki_DeviceZReport/search
image

Hi @kech

Thank you for reporting the problem. We have created a Github issue.

Regards,
Nadezhda.