When I use threading in my Google App Engine (GAE) app, the following warning shows up in IntelliJ:
App Engine application should not create new instances of 'java.lang.Thread'
My app is set to using Java 8. What is strange is that if I load the samples from Google's site, this warning does not show up in IntelliJ. So what is different? The code to creating a thread in my app looks like this:
new Thread(new StoreAccountWorker(startSignal, doneSignal)).start();
while the sample code from Google looks like this:
Runtime.getRuntime().addShutdownHook(new Thread() {
#Override
public void run() {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
HelloWorldServer.this.stop();
System.err.println("*** server shut down");
}
});
Oddly, if I paste the Google sample code into my app, the warning does not show up on the new Thread of Google's code but it does show up on my line of code.
This appears to be an issue with IntelliJ. I'm running IntelliJ 2016.2.4 which does not appear to recognize App Engine's support for threads in Java 8. To turn this warning off, go to IntelliJ's Preferences and under:
Editor > Code Style > Inspections
scroll down and disable "Google App Engine".
Related
I created Spring Boot + Google App Engine application. For development purpose I use IntelliJ IDEA and Google Cloud Tools plugin. I'm currently using only localDebug, which means I don't deploy anything on Google cloud. The configuration for debug is below:
I created a simple service to be sure if my code is updated on change or not:
static int i = 10;
#GetMapping(value = "/test")
public String test() {
return Integer.toString(++i);
}
Unfortunately when I change my code (e.g. from i = 10 to i = 100) and restart the app (I mean press on Rerun (Ctrl+F5) or Stop (Ctrl+F2) + Run my code doesn't apply on server, which means Idea doesn't rebuild the sources on server start. As you see on the screenshot above I even tried to add Build Project step to Before launch, which didn't work.
So to apply changes I need to execute from command line mvn appengine:run -> press Ctrl+C to stop it, switch to IDEA and start debug again which is a pain in the ass.
Another option is to use Hot Reload (Update application, Ctrl+F10). It recompiles only changed classes and reloads resources. This is a cool feature, but unfortunately it doesn't work in a lot of cases which makes me unable to use it as a reliable reload.
Is there anything I can do to force IDEA compile my sources? Is it a bug I should report to plugin developer. Or maybe appengine uses some additional remote sources that require explicit call of maven?
I finally found a solution. As I understood the Google cloud plugin just complies the classes into target/classes but when it starts the appEngine, the engine expected unpacked .war to be present under target/demo-0.0.1-SNAPSHOT.
E.g. if because if I delete both directories I get the error below:
To solve the issue I needed to compile those sources:
In toolbar Run -> Edit configuration
Select Google App Engine Standard Local server
In before launch add Build Artifact -> demo:war exploded where demo is the name of your App.
I am running a Java Microengine on GAE.
I have my own html pages for data input and output. When there is a data error and the engine cannot complete its execution (crashes) - the microengine spits out the "Response" as Server not available, please try later.
In order to debug, I run the dataset in the dev environment - as a Java application to identify the error in the console output.
Is there a way to capture the "error" (the console output equivalent when run as a Java application) - as an output string and send it as a content of the servlet response from the deployed Application in GAE..
thanks,
assuming you are using App Engine Managed VM, and a logging framework, you should also forward the log entry into a file, e.g. /var/log/app_engine/custom_logs/app.log
https://cloud.google.com/appengine/docs/managed-vms/custom-runtimes#logging
Subsequently, you'll be able to read the output from Google Cloud Logging.
Why am I getting "duplicate symbol _kCloudBackendClientID" compiling the project "solutions-mobile-backend-starter-ios-client-master" from Google?
This is right out of the box - I have xCode 5.0.2 (5A3005)
I am trying out their Mobile Backend Starter... ugh so tedious to get this working.
As of March 28 2014.. yes, the google app engine mobile backend starter for ios is a real pain in the a** to get working. I'm using XCode 5.1 and managed to get it all working after about 8 hours of trial and error.
The setup guide is here -
https://developers.google.com/cloud/samples/mbs/ios/
There are a lot of steps required to get the push notification certificates and provisioning profiles and app id's setup properly. One stumbling block is that when doing development builds, XCode forces your bundle identifier to have ".dev" at the end. Be sure you have this in the provisioning profile that you create with the attached push notification certificate.
There are several things broken with the code. First the compiler error:
1) Change #include "Constants.m" to #include "Constants.h" in MessagesTableViewController.m
Now the runtime errors:
2) Add Splash1/2/3ViewController.h and .m to the project. If you don't do this you get a crash on startup related to some exception related to UIViewController
3) Implement this in CloudBackendIOSClientAppDelegate.m
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
/* copy-paste the code from the previous didReceiveRemoteNotification */
//add this
if (handler)
handler(UIBackgroundFetchResultNoData);
}
This API seems to be new as of IOS7 and (I guess) is required to receive push notifications on IOS7.
The other thing I had to do was go into the app engine configuration on the app engine website. On the "Backends" tab, you have to make sure your 'worker' backend is started.
If you get all of this done properly you should be able to go down to the "Custom/Mobile Backend settings" tab, scroll to the bottom, and send a broadcast message successfully.
Hey Google people, if you are reading this you can compensate me with some free tech support on the next hurdles I have to jump through ;)
Code generated by Android Studio>tools>Google Cloud Tools> Generate App Engine Backend
and Generate Endpoint worked in the Emulator,
Intent intent = new Intent(this, RegisterActivity.class);
startActivity(intent);
however I got this error (image from another person's question)
http://i.stack.imgur.com/230G2.png
when I load the app onto my phone and run. (I did change the LOCAL_ANDROID_RUN to false)
The error implies that there is some Endpoint server running at http://10.0.2.2:8080
which I don't expect because I don't really understand where the Endpoint Service runs. Does it run locally on the phone or somewhere on the Cloud?
I believe generated App Engine code is shipped up to Google through the Maven appengine:update
What am I missing here, thanks
-a
UPDATE (11:24 AM)
executed:
Android Studio>tools>Google Cloud Tools> Generate Client Libraries
which added to -AppEngine/target/generated-sources/appengine-endpoints etc
This changed what happened on the phone. There is still a registration error but now says:
2) registration with Endpoints Server...FAILED!
Unable to register your device with your Cloud Endpoints server running at https://.appspot.com/_ah/api
UPDATE (11:44 AM)
executed maven script
appengine:update to get the AppEngine deployed with the new code from Generate Client Libraries
same error on phone (unable to register your device with your Cloud Endpoints server)
UPDATE (1:39 pm)
got logcat info while running app on the phone, hooked up through USB to computer,
looks like a 404 Not Found error (???)
12-27 13:36:51.942 609-703/? I/InputDispatcher﹕ Delivering touch to: action: 0x1
12-27 13:36:52.412 19103-19103/sic.example.db7 W/AbstractGoogleClient﹕ Application name is not set. Call Builder#setApplicationName.
12-27 13:36:52.412 19103-19246/sic.example.db7 E/GCMRegistrar﹕ internal error: retry receiver class not set yet
12-27 13:36:53.253 19103-19246/sic.example.db7 E/sic.example.db7.GCMIntentService﹕ Exception received when attempting to register with server at https://core-phoenix-441.appspot.com/_ah/api/
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
Not Found
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:111)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:38)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1042)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at sic.example.db7.GCMIntentService.onRegistered(GCMIntentService.java:158)
at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:296)
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:197)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:61)
the emulator can access because it runs locally, your phone doesn't have access to the computer localhost. To do that you can check Codiak answer.
https://stackoverflow.com/a/16097253/1368396
I came to know GAE cloud endpoints yesterday. From that time I am trying to generate APIs for my current web application. I am using JPA2.0, I chose one of my entity classes right clicked on it and then "generate Google endpoint class" . So now I have another class for this entity with #API annotations, etc.
But the problem is after deploying the app when I go to : https://developers.google.com/apis-explorer/?base=https://myAppId.appspot.com/_ah/api#p/
the services tab is empty. Same thing when I check it locally(Image below)
You need to Generate Cloud Endpoints Library (in Eclipse, right click on the Project, it's under Google) as well.
I had similar issue and it was caused by missing public attribute in methods.
#Api
public class MyApi {
#ApiMethod
void myMethod() { }
}
caused that I saw no methods. While added
#Api
public class MyApi {
#ApiMethod
public void myMethod() { }
}
methods started to be visible.
1.Login appengine
https://appengine.google.com/
2.Click the [Version] link in a Main category
3.Select your version and [Make Default] button
4.You can access the api explorer
https://myAppId.appspot.com/_ah/api/explorer
Best Regard.
I actually managed to resolve the above issue. So I had a web application existing and I thought I could just add annotations to it and have the APIs represented for it after deployment. But I realized that I had to start from scratch by creating an android app and then generate the back-end for that app and add my classes there. It now works. Thank you.
Points to remember before working on endpoints :
Need to create an endpoint client library before running your project.(In Eclipse : Project -> Right click -> Google -> Generate cloud endpoints library)
Check whether you are using latest Google Plugin or not. Because files required by endpoints will be executed from the plugin. If you are not able to generate the endpoint library. problem is with the plugin .Try updating it.
Endpoints will work only on default versions. Make sure that you made your version default.
finally try loading http://myApp.appspot.com/_ah/api/explorer. Everything should be fine now.