Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-7185

NullPointerException When Querying offset in ReST Events Endpoint

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 14.0.1
    • Fix Version/s: 15.0.0
    • Component/s: REST
    • Security Level: Default (Default Security Scheme)
    • Labels:

      Description

      When querying the events endpoint using the ReSTful API the server experiences a NullPointerException when counting the total number of events.

      Suggested fix is to clear the limit, offset and order clauses from the criteria builder like what was done in NodeRestService.java:

      crit.setLimit(null);
      crit.setOffset(null);
      crit.setOrders(new ArrayList<Order>());

      Below is the stack trace from the error:

      2014-11-17 14:40:20,831 WARN [qtp1812920108-23067 - /opennms/rest/events?eventSeverity=4&limit=20&offset=10] o.e.j.s.ServletHandler: /opennms/rest/events
      java.lang.NullPointerException
      at org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate$6.doInHibernate(AbstractDaoHibernate.java:305) ~[opennms-dao-14.0.1.jar:?]
      at org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate$6.doInHibernate(AbstractDaoHibernate.java:296) ~[opennms-dao-14.0.1.jar:?]
      at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:407) ~[org.apache.servicemix.bundles.spring-orm-3.2.9.RELEASE_1.jar:?]
      at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339) ~[org.apache.servicemix.bundles.spring-orm-3.2.9.RELEASE_1.jar:?]
      at org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate.countMatching(AbstractDaoHibernate.java:308) ~[opennms-dao-14.0.1.jar:?]
      at org.opennms.web.rest.EventRestService.getEvents(EventRestService.java:142) ~[opennms-webapp-14.0.1.jar:?]
      at org.opennms.web.rest.EventRestService$$FastClassBySpringCGLIB$$fec53bb9.invoke(<generated>) ~[org.apache.servicemix.bundles.spring-core-3.2.9.RELEASE_1.jar:?]
      at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[org.apache.servicemix.bundles.spring-core-3.2.9.RELEASE_1.jar:?]
      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) ~[org.apache.servicemix.bundles.spring-aop-3.2.9.RELEASE_1.jar:?]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) ~[org.apache.servicemix.bundles.spring-aop-3.2.9.RELEASE_1.jar:?]
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) ~[org.apache.servicemix.bundles.spring-tx-3.2.9.RELEASE_1.jar:?]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) ~[org.apache.servicemix.bundles.spring-tx-3.2.9.RELEASE_1.jar:?]
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) ~[org.apache.servicemix.bundles.spring-tx-3.2.9.RELEASE_1.jar:?]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) ~[org.apache.servicemix.bundles.spring-aop-3.2.9.RELEASE_1.jar:?]
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) ~[org.apache.servicemix.bundles.spring-aop-3.2.9.RELEASE_1.jar:?]
      at org.opennms.web.rest.EventRestService$$EnhancerBySpringCGLIB$$a9e517d4.getEvents(<generated>) ~[org.apache.servicemix.bundles.spring-core-3.2.9.RELEASE_1.jar:?]
      at sun.reflect.GeneratedMethodAccessor793.invoke(Unknown Source) ~[?:?]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_71]
      at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_71]
      at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) ~[jersey-server-1.18.1.jar:1.18.1]
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) ~[jersey-servlet-1.18.jar:1.18]
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540) ~[jersey-servlet-1.18.jar:1.18]
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715) ~[jersey-servlet-1.18.jar:1.18]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) ~[javax.servlet-2.5.0.v201103041518.jar:?]
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1317) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.opennms.container.web.felix.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:53) ~[?:?]
      at org.opennms.container.web.felix.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:35) ~[?:?]
      at org.opennms.container.web.felix.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:50) ~[?:?]
      at org.opennms.container.web.felix.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:42) ~[?:?]
      at org.opennms.container.web.bridge.internal.DispatcherFilter.doFilter(DispatcherFilter.java:72) ~[?:?]
      at org.opennms.container.web.ProxyFilter.doFilter(ProxyFilter.java:56) ~[org.opennms.container.servlet-14.0.1.jar:?]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(AbstractExportFilter.java:49) ~[extremecomponents-1.0.1.jar:1.0.1]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.opennms.web.servlet.AddAccessControlHeaderFilter.doFilter(AddAccessControlHeaderFilter.java:55) ~[opennms-web-api-14.0.1.jar:?]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.opennms.web.servlet.StoreRequestPropertiesFilter.doFilter(StoreRequestPropertiesFilter.java:79) ~[opennms-web-api-14.0.1.jar:?]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.opennms.web.springframework.security.AuthFilterEnabler.doFilter(AuthFilterEnabler.java:108) ~[org.opennms.features.springframework-security-14.0.1.jar:?]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) ~[spring-security-web-3.1.7.RELEASE.jar:3.1.7.RELEASE]
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) ~[org.apache.servicemix.bundles.spring-web-3.2.9.RELEASE_1.jar:?]
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) ~[org.apache.servicemix.bundles.spring-web-3.2.9.RELEASE_1.jar:?]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:232) ~[org.apache.servicemix.bundles.spring-orm-3.2.9.RELEASE_1.jar:?]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) ~[org.apache.servicemix.bundles.spring-web-3.2.9.RELEASE_1.jar:?]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) ~[org.apache.servicemix.bundles.spring-web-3.2.9.RELEASE_1.jar:?]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) ~[org.apache.servicemix.bundles.spring-web-3.2.9.RELEASE_1.jar:?]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288) ~[jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:443) [jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556) [jetty-security-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372) [jetty-servlet-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.Server.handle(Server.java:365) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:933) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:995) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644) [jetty-http-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) [jetty-server-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667) [jetty-io-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) [jetty-io-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-7.6.15.v20140411.jar:7.6.15.v20140411]
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-7.6.15.v20140411.jar:7.6.15.v20140411]
      at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              coreyh Corey Hammerton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: