It seems as if the method from the endpoint class itself is not being called as none of the print statements I put in to debug gave any output
好像来自端点类本身的方法没有被调用,因为我输入调试的所有打印语句都没有给出任何输出
RELEVANT CODE
相关代码
accessing the TransLogEndpoint class
访问TransLogEndpoint类
Translogendpoint.Builder builder = new Translogendpoint.Builder(
AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
null);
builder = CloudEndpointUtils.updateBuilder(builder);
Translogendpoint endpoint = builder.build();
I ended up hardcoding the object I wanted to insert
我最终硬编码了我想要插入的对象
TransLog t=new TransLog();
t.setId(33);
t.setOperation("ins");
t.setTable("hisone");
t.setTransTime((long) 299221212);
t.setAcc("meh");
And tried to insert as such
并尝试插入这样的
try {
endpoint.insertTransLog(t).execute();
} catch (IOException e) {
System.out.println("could not insert Log");
// TODO Auto-generated catch block
e.printStackTrace();
}
This is how the endpoint method for inserting the TransLog looks I did not change any of its logic
这就是插入TransLog的端点方法看起来我没有改变它的任何逻辑
@ApiMethod(name = "insertTransLog")
public TransLog insertTransLog(TransLog translog) {
System.out.println("I am here");
Key k=KeyFactory.createKey("TransLog",translog.getId());
translog.setKey(k);
EntityManager mgr = getEntityManager();
try {
if(containsTransLog(translog)) {
throw new EntityExistsException("Object already exists");
}
mgr.persist(translog);
} finally {
mgr.close();
}
return translog;
}
}
this is from the App Engine [Web Application Console]
这是来自App Engine [Web应用程序控制台]
Jun 21, 2014 2:03:15 PM com.google.api.server.spi.SystemService invokeServiceMethod
INFO: cause={0}
java.lang.NullPointerException
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:318)
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:256)
at com.example.agriexpensett.TransLogEndpoint.containsTransLog(TransLogEndpoint.java:154)
at com.example.agriexpensett.TransLogEndpoint.insertTransLog(TransLogEndpoint.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:127)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:85)
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.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
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 com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
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.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
and
和
Jun 21, 2014 2:03:15 PM com.google.api.server.spi.SystemService invokeServiceMethod
SEVERE: null
java.lang.NullPointerException
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:318)
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:256)
at com.example.agriexpensett.TransLogEndpoint.containsTransLog(TransLogEndpoint.java:154)
at com.example.agriexpensett.TransLogEndpoint.insertTransLog(TransLogEndpoint.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:127)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:85)
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.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
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 com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
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.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
1 个解决方案
#1
0
Your stacktrace says :
你的stacktrace说:
...
at com.example.agriexpensett.TransLogEndpoint.containsTransLog(TransLogEndpoint.java:154)
Maybe your issue is because the KeyFactory.createKey return a null value, so when it come to call containsTransLog, the method fire a NPE in containsTransLog.
也许你的问题是因为KeyFactory.createKey返回一个空值,所以当它调用containsTransLog时,该方法在containsTransLog中触发一个NPE。
I was able to fix this kind of issue by changing the default generated "contains..." method. So, you can try to change your containsTransLog method to take care of the NPE, by adding a check on your Key value :
我能够通过更改默认生成的“包含...”方法来解决此类问题。因此,您可以尝试更改containsTransLog方法以处理NPE,方法是添加对Key值的检查:
@ApiMethod(name = "containsTransLog")
public boolean containsTransLog(TransLog translog) {
if(translog.getKey() ==null)
return false;
EntityManager mgr = getEntityManager();
//...
}
You can also check if the value of "Key k" is null.
您还可以检查“Key k”的值是否为空。
Hope this helps !
希望这可以帮助 !
#1
0
Your stacktrace says :
你的stacktrace说:
...
at com.example.agriexpensett.TransLogEndpoint.containsTransLog(TransLogEndpoint.java:154)
Maybe your issue is because the KeyFactory.createKey return a null value, so when it come to call containsTransLog, the method fire a NPE in containsTransLog.
也许你的问题是因为KeyFactory.createKey返回一个空值,所以当它调用containsTransLog时,该方法在containsTransLog中触发一个NPE。
I was able to fix this kind of issue by changing the default generated "contains..." method. So, you can try to change your containsTransLog method to take care of the NPE, by adding a check on your Key value :
我能够通过更改默认生成的“包含...”方法来解决此类问题。因此,您可以尝试更改containsTransLog方法以处理NPE,方法是添加对Key值的检查:
@ApiMethod(name = "containsTransLog")
public boolean containsTransLog(TransLog translog) {
if(translog.getKey() ==null)
return false;
EntityManager mgr = getEntityManager();
//...
}
You can also check if the value of "Key k" is null.
您还可以检查“Key k”的值是否为空。
Hope this helps !
希望这可以帮助 !