GAE and Objectify query and error using order() - google-app-engine

I am just working on a Demo project and one of the methods provides a basic query on a Type.
public List<Conference> filterPlayground(){
Query<Conference> query = (ofy().load().type(Conference.class)).order("name");
query = query.filter("topics =", "Medical Innovations");
query = query.filter("city =","London");
return query.list();
}
My Conference Entity has #Index for name, city and topics.
But when I run the method in API Explorer I get an Exception... (see below). Any quick pointers as to why using the order method causes this. I know it is the order method as without it there is no error.
Uncaught exception from servlet
java.io.IOException: com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingExcepti on: no matching index found. recommended index is:
- kind: Conference
properties:
- name: city
- name: topics
- name: name
The suggested index for this query is:
<datastore-index kind="Conference" ancestor="false" source="manual">
<property name="city" direction="asc"/>
<property name="topics" direction="asc"/>
<property name="name" direction="asc"/>
</datastore-index>
(through reference chain: java.util.HashMap["items"])
at com.google.api.server.spi.response.ServletResponseResultWriter.writeValueAs String(ServletResponseResultWriter.java:187)
at com.google.api.server.spi.response.ServletResponseResultWriter.write(ServletResponseResultWriter.java:74)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:394)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:113)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:71)
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.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
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.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:145)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:511)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:446)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:453)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:276)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:312)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:304)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:450)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: no matching index found. recommended index is:
- kind: Conference
properties:
- name: city
- name: topics
- name: name
The suggested index for this query is:
<datastore-index kind="Conference" ancestor="false" source="manual">
<property name="city" direction="asc"/>
<property name="topics" direction="asc"/>
<property name="name" direction="asc"/>
</datastore-index>
(through reference chain: java.util.HashMap["items"])
at com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:218)
at com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:183)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.SerializerBase.wrapAndThrow(SerializerBase.java:140)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.MapSerializer.serializeFields(MapSerializer.java:266)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.MapSerializer.serialize(MapSerializer.java:186)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.MapSerializer.serialize(MapSerializer.java:23)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ObjectWriter._configAndWriteValue(ObjectWriter.java:456)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ObjectWriter.writeValueAsString(ObjectWriter.java:393)
at com.google.api.server.spi.response.ServletResponseResultWriter.writeValueAsString(ServletResponseResultWriter.java:183)
... 38 more
Caused by: com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found. recommended index is:
- kind: Conference
properties:
- name: city
- name: topics
- name: name
The suggested index for this query is:
at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:59)
at com.google.appengine.api.datastore.DatastoreApiHelper$1.convertException(DatastoreApiHelper.java:128)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:97)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:89)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:76)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:36)
at com.google.appengine.api.datastore.BaseQueryResultsSource.getIndexList(BaseQueryResultsSource.java:159)
at com.google.appengine.api.datastore.BaseQueryResultsSource.loadMoreEntities(BaseQueryResultsSource.java:192)
at com.google.appengine.api.datastore.BaseQueryResultsSource.loadMoreEntities(BaseQueryResultsSource.java:171)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.ensureLoaded(QueryResultIteratorImpl.java:148)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.hasNext(QueryResultIteratorImpl.java:64)
at com.googlecode.objectify.impl.KeysOnlyIterator.hasNext(KeysOnlyIterator.java:29)
at com.googlecode.objectify.impl.ChunkIterator.next(ChunkIterator.java:48)
at com.googlecode.objectify.impl.ChunkIterator.next(ChunkIterator.java:20)
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:597)
at com.google.common.collect.Iterators$PeekingImpl.hasNext(Iterators.java:1216)
at com.googlecode.objectify.impl.ChunkingIterator.hasNext(ChunkingIterator.java:51)
at com.google.common.collect.Lists.newArrayList(Lists.java:144)
at com.google.common.collect.Lists.newArrayList(Lists.java:125)
at com.googlecode.objectify.util.MakeListResult.translate(MakeListResult.java:21)
at com.googlecode.objectify.util.MakeListResult.translate(MakeListResult.java:11)
at com.googlecode.objectify.util.ResultTranslator.nowUncached(ResultTranslator.java:21)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.util.ResultProxy.invoke(ResultProxy.java:34)
at com.sun.proxy.$Proxy30.iterator(Unknown Source)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:45)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86)
at com.google.appengine.repackaged.org.codehaus.jackson.map.ser.std.MapSerializer.serializeFields(MapSerializer.java:262)
... 45 more

Your app needs a different index definition for ordered queries. A direction is needed as well. See
How to fix index error when querying GAE datastore?
Typically the devserver is able to automatically generate/update the indexes in your local development environment according to the queries your local app actually performs. But you need to manually upload the updated index file to GAE (and make sure indexing is completed) before your GAE app can actually use it.
If the devserver fails to automatically generate/update the index file you can still do it manually.

The error basically tells you everything you need to know. You should add:
<datastore-index kind="Conference" ancestor="false" source="manual">
<property name="city" direction="asc"/>
<property name="topics" direction="asc"/>
<property name="name" direction="asc"/>
</datastore-index>
to your index configuration.
It doesn't matter that you have individual indexes on these properties. You need to create a composite index (as described in the error message) for this query.

Related

Graph API to get all AAD Properties

Is there a Graph API which can be used to get a list of all properties which AAD supports. I dont need these properties to be user specific. All I need is the name of the properties (ex - firstname, lastname, phoneNo etc).I dont need to hard code these properties in my code I want to know if there is any API to get all the properties name. I only have tenant related data like tenant Id.
The closest thing that you might be looking for is probably the EDM metadata available here: https://graph.microsoft.com/v1.0/$metadata.
It's in XML, but if you parse it and find the EntityType element with Name="user" attribute, you can see what properties it has:
<EntityType Name="user" BaseType="graph.directoryObject" OpenType="true">
<Property Name="accountEnabled" Type="Edm.Boolean"/>
<Property Name="ageGroup" Type="Edm.String"/>
<Property Name="assignedLicenses" Type="Collection(graph.assignedLicense)" Nullable="false"/>
<Property Name="assignedPlans" Type="Collection(graph.assignedPlan)" Nullable="false"/>
<Property Name="businessPhones" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="city" Type="Edm.String"/>
<Property Name="companyName" Type="Edm.String"/>
<Property Name="consentProvidedForMinor" Type="Edm.String"/>
<Property Name="country" Type="Edm.String"/>
<Property Name="creationType" Type="Edm.String"/>
<Property Name="department" Type="Edm.String"/>
<Property Name="displayName" Type="Edm.String"/>
<!-- Lot of other properties... -->
</EntityType>
The OpenAPI documents are also available in GitHub: https://github.com/microsoftgraph/microsoft-graph-openapi.
They aren't available through a URL like the EDM metadata, but seems that is future plan:
Our plans are to expose the OpenAPI descriptions for Microsoft Graph as part of the service itself

Composite index in datastore-index.xml not created

Here is my datastore-index file:
<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
<datastore-index kind="Stock" ancestor="false" source="manual">
<property name="code" direction="asc" />
<property name="endTime" direction="asc" />
</datastore-index>
</datastore-indexes>
The index entry was created exactly as suggested by App Engine in error log.
I put the index file in folder webapp/WEB-INF.
Despite all my efforts, no index were necer displayed on the Datastore index page and when I query I get the same error message: no matching index found.
Could you help me?

GAE Java- Null pointer exception when trying to retrieve an object

I am new to GAE development.
for me insertion using jpa to the datastore is working fine, but retrieval is not happening.
Below is a method which authenticates the user when he try to login.
public boolean loginUser(User user) {
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("SOAApp");
EntityManager mgr = emf.createEntityManager();
boolean login=false;
Query query=mgr.createQuery("select u from User u where u.userName=:uid and u.password=:pwd");
query.setParameter("uid", user.getUserName());
query.setParameter("pwd",user.getPassword());
query.setMaxResults(1);
try {
user=(User) query.getSingleResult();
System.out.println("user : "+user.getName());
if(user!=null) {
System.out.println("logged in...");
login=true;
}
}
catch(Exception e) {
e.printStackTrace();
}
finally {
mgr.close();
}
return login;
}
but I am getting the following errors when trying to execute the method by passing a user object with valid username and password.
java.lang.NullPointerException
at com.google.appengine.datanucleus.query.QueryEntityPKFetchFieldManager.fetchIntField(QueryEntityPKFetchFieldManager.java:70)
at org.datanucleus.identity.IdentityUtils.getApplicationIdentityForResultSetRow(IdentityUtils.java:93)
at com.google.appengine.datanucleus.EntityUtils.entityToPojo(EntityUtils.java:1009)
at com.google.appengine.datanucleus.query.DatastoreQuery$2.apply(DatastoreQuery.java:228)
at com.google.appengine.datanucleus.query.DatastoreQuery$2.apply(DatastoreQuery.java:225)
at com.google.appengine.datanucleus.query.LazyResult.resolveNext(LazyResult.java:96)
at com.google.appengine.datanucleus.query.LazyResult.resolveAll(LazyResult.java:121)
at com.google.appengine.datanucleus.query.LazyResult.size(LazyResult.java:115)
at com.google.appengine.datanucleus.query.StreamingQueryResult.size(StreamingQueryResult.java:151)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1808)
at org.datanucleus.store.query.Query.executeWithMap(Query.java:1693)
at org.datanucleus.api.jpa.JPAQuery.getSingleResult(JPAQuery.java:231)
at com.soa.managers.UserManager.loginUser(UserManager.java:63)
at com.soa.servlets.LoginServlet.doPost(LoginServlet.java:48)
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:123)
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:61)
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.BackendServersFilter.doFilter(BackendServersFilter.java:97)
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:94)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:383)
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)
Nov 03, 2012 3:25:02 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
line number-63
[at com.soa.managers.UserManager.loginUser(UserManager.java:63)]
is "user=(User) query.getSingleResult();"
Please help me
Still searching?
I had the same problem and my entity User had a primaryKey named userId that was of type 'int'. Now I changed it to 'Long' and all of my problems and warnings are all gone! Maybe this helps you out!
I look forward hearing from you!
Regards,
Stephan
The reason why u get nullpointerexception is that getSingleResult method returns null. Because u used (User)query.getSingleResult(), the typecasting of null value throws exception.
I think there is no related user in datastore, so you are getting exception.
<?xml version="1.0" encoding="UTF-8"?>
<datastore-indexes autoGenerate="true">
<datastore-index kind="HABERLER" ancestor="false" source="manual">
<property name="__key__" direction="desc"/>
</datastore-index>
HABERLER is table name. Write your table name instead of HABERLER. Then create a datastore-indexes.xml file in WEB-INF directory. Then copy above code into this file.
Make sure you that the keys for your entities are of valid types as detailed here:
https://developers.google.com/appengine/docs/java/datastore/jdo/creatinggettinganddeletingdata#Keys
The exception you are getting is most likely related to a key issue.

GAE ConcurrentModificationException while commiting

I'm testing a GAE application with JPA deployed on localhost with jetty provided by the SDK (version 1.7.1).
At every commit the framework raise a ConcurrentModificationException, but the object persist in the datastore.
There's something I'm doing wrong? Tnx in advance
appengine-api-1.0-sdk-1.7.1
datanucleus-api-jpa-3.1.2
datanucleus-core-3.1.2
datanucleus-appengine-2.1.0-final
Transaction failed to commit
org.datanucleus.transaction.NucleusTransactionException: Transaction failed to commit
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:365)
at it.gustaff.core.PlaceRService.createPlace(PlaceRService.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
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.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
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.BackendServersFilter.doFilter(BackendServersFilter.java:97)
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:94)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:370)
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)
Caused by: java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection.close(DatastoreConnectionFactoryImpl.java:146)
at org.datanucleus.store.connection.ConnectionManagerImpl$2.transactionCommitted(ConnectionManagerImpl.java:296)
at org.datanucleus.TransactionImpl.internalPostCommit(TransactionImpl.java:577)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:354)
... 51 more
<persistence-unit name="appengine-transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>it.gustaff.data.Place</class>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.singletonEMFForName" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
public Place createPlace(Place p){
EntityManager entityManager = EMF.get().createEntityManager();
entityManager.getTransaction().begin();
//avoid to persist a Place with an Id already set
p.setId(null);
entityManager.persist(p);
ExecutionContext ec = (ExecutionContext) entityManager.getDelegate();
ec.getTransaction().commit();
entityManager.close();
return p;
}
#Entity
public class Place {
private String name;
private String description;
private String address;
//omitted other getter/setter
private com.google.appengine.api.datastore.Key id;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
public Key getId() {
return id;
}
public void setId(Key id) {
this.id = id;
}
}
You don't quote your entity and what p.setId(null) is doing. That aside something you can try (to find where the real ConcurrentModificationException is happening) is (something like) replace the entityManager.getTransaction().commit() with this
ExecutionContext ec = (ExecutionContext)entityManager.getDelegate();
ec.getTransaction().commit();
If this throws a NucleusTransactionException then print out the stack trace with the cause and add it to your question. The cause is where the real problem is, and if its a problem in GAE then it can be fixed, otherwise if its a problem in your code then you know where it is.

how to deal with datastore-indexes app engine?

for this example LINK
i try to make it but this exception occurred ??
com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
<datastore-index kind="Contact" ancestor="true" source="manual">
<property name="UserContacts_INTEGER_IDX" direction="asc"/>
</datastore-index>
how can i write these indexes manually ?? i try to make WEB-INF/datastore-indexes.xml
at this XML i write the following :
<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
<datastore-index kind="Contact" ancestor="true" source="manual">
<property name="UserContacts_INTEGER_IDX" direction="asc"/>
</datastore-index>
but when Iam going to deploy this error stop me to continue deploying
An internal error occurred during: "Deploying store to Google".
XML error validating
So how can i get these indexes ??
another issues >>
when i run this code and add some properties at User class as
#Persistent (mappedBy = "userC")
public List<Contact> UserContacts =new ArrayList<Contact>();
and deploy it , the engine make indexes for the UserContacts however appear Exception due to the new property - same error above can't make indexes to them -
The best thing for you to do is run you app locally and perform some test queries on those entities.
As you have <datastore-indexes autoGenerate="true"> in your indexes config you should get a file called
WEB-INF/appengine-generated/datastore-indexes-auto.xml
in there you should get all the index definitions needed for your app to work.
Copy those index definitions to your WEB-INF/datastore-indexes.xml and update your app.
If you go to your cloud console and check on your Storage/datastore/indexes view you should be all those indexed either building or serving. Once all those indexes are on "serving" you should be good to go.

Resources