我正在做一个基本的JDO查询来搜索到昨天工作良好的用户,但是知道我得到了这个内部异常而没有(显然)在我的代码中没有改变任何内容。 它发生在开发和生产服务器上。
简单查询:
PersistenceManager pm = getPersistenceManager();
Query query = pm.newQuery(KomiUser.class);
query.setFilter("email == emailParam");
query.declareParameters("String emailParam");
List<KomiUser> results = (List<KomiUser>) query.execute(email);
if (results != null && results.size() > 0)
return results.get(0); //should be only one
return null;
这是stacktrace:
sep 03, 2014 11:00:15 AM com.google.api.server.spi.SystemService invokeServiceMethod
Información: cause={0}
java.lang.NoSuchMethodError: com.google.appengine.api.datastore.Cursor: method <init>()V not found
at com.google.appengine.api.datastore.QueryResultIteratorImpl.<init>(QueryResultIteratorImpl.java:52)
at com.google.appengine.api.datastore.PreparedQueryImpl.runQuery(PreparedQueryImpl.java:39)
at com.google.appengine.api.datastore.PreparedQueryImpl.asQueryResultIterator(PreparedQueryImpl.java:69)
at com.google.appengine.api.datastore.BasePreparedQuery$2.iterator(BasePreparedQuery.java:45)
at com.google.appengine.api.datastore.BasePreparedQuery$2.iterator(BasePreparedQuery.java:42)
at com.google.appengine.datanucleus.query.RuntimeExceptionWrappingIterable$1.get(RuntimeExceptionWrappingIterable.java:49)
at com.google.appengine.datanucleus.query.RuntimeExceptionWrappingIterable$1.get(RuntimeExceptionWrappingIterable.java:47)
at com.google.appengine.datanucleus.query.QueryExceptionWrappers$1.get(QueryExceptionWrappers.java:49)
at com.google.appengine.datanucleus.query.QueryExceptionWrappers$2.get(QueryExceptionWrappers.java:68)
at com.google.appengine.datanucleus.query.RuntimeExceptionWrappingIterable.iterator(RuntimeExceptionWrappingIterable.java:57)
at com.google.appengine.datanucleus.query.LazyResult.<init>(LazyResult.java:70)
at com.google.appengine.datanucleus.query.StreamingQueryResult.<init>(StreamingQueryResult.java:67)
at com.google.appengine.datanucleus.query.DatastoreQuery.newStreamingQueryResultForEntities(DatastoreQuery.java:442)
at com.google.appengine.datanucleus.query.DatastoreQuery.wrapEntityQueryResult(DatastoreQuery.java:421)
at com.google.appengine.datanucleus.query.DatastoreQuery.performExecute(DatastoreQuery.java:343)
at com.google.appengine.datanucleus.query.JDOQLQuery.performExecute(JDOQLQuery.java:164)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1789)
at org.datanucleus.store.query.Query.executeWithArray(Query.java:1666)
at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:243)
at com.meanwhile.komi.head.users.UserDataAccess.getUserByEmail(UserDataAccess.java:21)
at com.meanwhile.komi.head.UserEndpoint.insertKomiUser(UserEndpoint.java:84)
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:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
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.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)
我的build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.10'
}
}
repositories {
mavenCentral();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.10'
compile 'com.google.appengine:appengine-endpoints:1.9.10'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.10'
compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
compile 'javax.servlet:servlet-api:2.5'
compile 'org.ow2.asm:asm:4.0'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:4.0b3'
compile 'com.ganyo:gcm-server:1.0.2'
compile 'javax.jdo:jdo-api:3.0.1'
compile 'javax.transaction:jta:1.1'
compile 'org.datanucleus:datanucleus-core:3.1.3'
compile 'org.datanucleus:datanucleus-api-jdo:3.1.3'
}
我的用户类:
@PersistenceCapable
public class KomiUser {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
private String key;
@Persistent
private String email;
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private String img;
@Persistent (defaultFetchGroup = "false", mappedBy = "user")
@Order(extensions = @Extension(vendorName ="datanucleus", key = "list-ordering", value = "date desc"))
private List<Review> reviews;
...
}
感谢您的时间
答案 0 :(得分:0)
最后,我通过使用以下依赖项来完成这项工作:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.10'
compile 'com.google.appengine:appengine-endpoints:1.9.10'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.10'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.ganyo:gcm-server:1.0.2'
compile 'javax.jdo:jdo-api:3.0.1'
compile 'org.datanucleus:datanucleus-core:3.1.3'
compile 'org.datanucleus:datanucleus-api-jdo:3.1.3'
compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
}
答案 1 :(得分:0)
请使用所有依赖项的较新版本,您可以在http://mvnrepository.com/
找到最新版本然后,继续观看最新版本并更新SDK和所有依赖项。
答案 2 :(得分:0)
我遇到了同样的问题,我通过改变Objectify版本解决了这个问题:
compile 'com.googlecode.objectify:objectify:4.0b3'
要:
compile 'com.googlecode.objectify:objectify:5.0.3'