从Google Cloud端点获取例外

时间:2014-10-03 07:20:41

标签: java google-app-engine cordova google-cloud-endpoints

    We have developed mobile application by using phonegap. We are connecting to the backend by using Google Cloud endpoints. We have written our api's at server side
    using java(Google App engine) to get the data. Every thing was working fine but suddenly i got the following exception:

代码段:         com.google.api.server.spi.SystemService invokeServiceMethod:cause = {0}
        显示java.lang.NullPointerException
            在com.veersoft.services.api.ListTenantAPI.listTenant(ListTenantAPI.java:49)             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)             在java.lang.reflect.Method.invoke(Method.java:45)             在com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)             在com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)             在com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)             在javax.servlet.http.HttpServlet.service(HttpServlet.java:637)             在javax.servlet.http.HttpServlet.service(HttpServlet.java:717)             在org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1166)             在com.google.appengine.tools.appstats.AppstatsFilter.doFilter(AppstatsFilter.java:142)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)             在com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)             在com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在com.veersoft.filter.ResetUserMessagesAndErrorsFilter.doFilter(ResetUserMessagesAndErrorsFilter.java:30)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)             在com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)             在org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)             在org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)             在org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)             在org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)             在org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)             在org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)             在org.mortbay.jetty.Server.handle(Server.java:326)             在org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)             at org.mortbay.jetty.HttpConnection $ RequestHandler.headerComplete(HttpConnection.java:923)             在org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)             在com.google.tracing.TraceContext $ TraceContextRunnable.runInContext(TraceContext.java:438)             在com.google.tracing.TraceContext $ TraceContextRunnable $ 1.run(TraceContext.java:445)             在com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)             在com.google.tracing.TraceContext $ AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)             在com.google.tracing.TraceContext $ AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)             在com.google.tracing.TraceContext $ TraceContextRunnable.run(TraceContext.java:442)             在java.lang.Thread.run(Thread.java:724)

    E 2014-10-03 10:00:48.322

    com.google.api.server.spi.SystemService invokeServiceMethod: null
    java.lang.NullPointerException
        at com.veersoft.services.api.ListTenantAPI.listTenant(ListTenantAPI.java:49)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:45)
        at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
        at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
        at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
        at com.google.appengine.tools.appstats.AppstatsFilter.doFilter(AppstatsFilter.java:142)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.veersoft.filter.ResetUserMessagesAndErrorsFilter.doFilter(ResetUserMessagesAndErrorsFilter.java:30)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
        at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:438)
        at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
        at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
        at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
        at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
        at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
        at java.lang.Thread.run(Thread.java:724)

数据在一段时间后变好了,但我不知道为什么突然出现上述异常,我担心它可能会在将来发生?我已经完成了我的api,一切都很好。 请问有谁可以告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

如果查看堆栈跟踪,很明显您的Endpoints API方法(com.veersoft.services.api.ListTenantAPI.listTenant)是空指针异常(NPE)发生的位置。在没有看到您的代码的情况下,我们无法知道确切的NPE是什么,但堆栈跟踪确实为您提供了行号,因此您可以在第49行检查ListTenantAPI.java以找出发生了什么

您需要查看您的客户端代码,并可能进入phonegap,以找出listTenant()投掷NPE的原因。