How to connect the GAE application and the GCE application to the same data warehouse locally?

I am having a problem similar to this . I have a GAE application and a GCE application that seems to work fine in the cloud, but it's hard for me to work with the on-premises environment so that they both access the same data store.

I installed a local data store, as described in the link above, except that my code looks like this (I had to build it in such a way as to make it work in the cloud):

print("Connecting to datastore - " + datasetId);

// Get credentials form GCE if not local.
Credential computeEngineCredential = DatastoreHelper.getComputeEngineCredential();

if(computeEngineCredential != null)
{
    print("Compute Engine Credetianls are not null! Access token: " + computeEngineCredential.getAccessToken());
}

DatastoreOptions options = DatastoreHelper.getOptionsfromEnv().credential(DatastoreHelper.getComputeEngineCredential()).dataset(datasetId).build();

print("Connection Host: " + options.getHost());
print("Connection Dataset: " + options.getDataset());

datastore = DatastoreFactory.get().create(options);

When I launch the GCE application locally and try to connect to a working GAE datastore, I get the following (I replaced the actual dataset identifier with "myDatasetId" in the output below):

- "myDatasetId"

Connection Host: http://localhost:8888

: "myDatasetId"

com.google.api.services.datastore.client.DatastoreFactory makeClient

:

: : runQuery 404

404

    com.google.api.services.datastore.client.DatastoreException: 404

404

        at com.google.api.services.datastore.client.RemoteRpc.makeException(RemoteRpc.java:114)          com.google.api.services.datastore.client.RemoteRpc.call(RemoteRpc.java:80)         at com.google.api.services.datastore.client.Datastore.runQuery(Datastore.java:109)

GAE ( 8888 ):

com.google.appengine.tools.development.AbstractModule startup

INFO: http://localhost:8888/_ah/admin

com.google.appengine.tools.development.LocalResourceFileServlet doGet

: :

//v1beta2/ / "myDatasetId" /runQuery

GCE GAE. , ( gcd.cmd- GCE). , , , - ?

, , GCD Tool :

SEVERE: App Engine. . java.lang.RuntimeException: .          com.google.apphosting.utils.clearcast.ClearCast $CasterImpl.cast(ClearCast.java:385)          com.google.apphosting.utils.clearcast.ClearCast.staticCast(ClearCast.java:252)          com.google.apphosting.utils.clearcast.ClearCast.staticCast(ClearCast.java:263)         at com.google.appengine.tools.development.agent.AppEngineDevAgent.premain(AppEngineDevAgent.java:61)         at sun.reflect.NativeMethodAccessorImpl.invoke0 ( )         at sun.reflect.NativeMethodAccessorImpl.invoke( )         at sun.reflect.DelegatingMethodAccessorImpl.invoke( )          java.lang.reflect.Method.invoke( )         at sun.instrument.InstrumentationImpl.loadClassAndStartAgent( )         at sun.instrument.InstrumentationImpl.loadClassAndCallPremain( ) : java.lang.IllegalAccessException: Class com.google.apphosting.utils.clearcast.ClearCast $CasterImpl cess com.google.appengine.tools.development.agent. $Proxy0 ""         at sun.reflect.Reflection.ensureMemberAccess( )          java.lang.reflect.AccessibleObject.slowCheckMemberAccess( )          java.lang.reflect.AccessibleObject.checkAccess( )          java.lang.reflect.Constructor.newInstance( )          com.google.apphosting.utils.clearcast.ClearCast $CasterImpl.cast(ClearCast.java:383)         ... 9

, - GAE GCD Tool? .

+3
2

Datastore Java Development Server (dev_appserver.sh) (gcd.sh).

, Java, , , dev_appserver.sh , gcd.sh, -Ddatastore.backing_store=<project dir>/WEB-INF/appengine-generated/local_db.bin.

+2

, . GAE local_db.bin, gcd eclipse, "-Ddatastore.backing_store" , .

. admin GAE, 8888 , , GAE, , gcd, gcd (8080), , GCE.

, , GAE GCE, , , , Entity , , . , GCE , GAE , - , , , , , local_db.bin, , .

dev_appserver.cmd ? , EAR ( ).

0

Source: https://habr.com/ru/post/1613439/


All Articles