How to deploy GWT GAE applications on external server - google-app-engine

I Have an GWT+GAE application with nosql database that runs fine in Google App Engine and in eclipse + gwt plugin with embedded jetty server on development environment.
Now in production environment, for many causes, i have to deploy this application on an external self managed server like Tomcat or JBoss.
I follow with no luck many tutorials and tips&tricks like:
https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#How_do_I_use_my_own_server_in_development_mode_instead_of_GWT%27s
https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/LYySmvqdbO8
or Link1 Link2 Link3 Link4 Link5
When I deploy my application on an external server (i.e. tomcat or jetty) it starts correctly but when I do a call that uses database connection it gives this error:
Caused by: java.lang.NullPointerException: No API environment is registered for this thread.
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:86)
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamespace(DatastoreApiHelper.java:96)
at com.google.appengine.api.datastore.Query.<init>(Query.java:171)
at com.google.appengine.api.datastore.Query.<init>(Query.java:102)
at com.googlecode.objectify.impl.QueryImpl.<init>(QueryImpl.java:69)
at com.googlecode.objectify.impl.AsyncObjectifyImpl.query(AsyncObjectifyImpl.java:354)
at com.googlecode.objectify.impl.ObjectifyImpl.query(ObjectifyImpl.java:207)
at com.beoui.geocell.ObjectifyGeocellQueryEngine.query(ObjectifyGeocellQueryEngine.java:52)
at com.beoui.geocell.GeocellManager.proximitySearch(GeocellManager.java:381)
How can I deploy to external servers like Tomcat, JBOSS or Jetty?
Or it isn't possible at all?
My opinion is: whether the application runs correctly on eclipse embedded jetty, in some way is possible to configure an external jetty distribution to run the application

GAE comes with a set of services which are basically big external systems hidden behind an API. Local dev server is just a Jetty with an embedded database and an API layer mimicking the production GAE. You can not use the dev server for production purposes - it was not made for this and has no concurrency and reliability features of production system.
If you want to run GAE code somewhere else then production GAE service, take a look at AppScale or CapeDwarf.
Also, most links that you provided deal with running GWT app on Tomcat/Jetty, but you have problems with AppEngine. GWT and AppEngine are two separate technologies (which can work together, but it's not required).

Related

How to connect Google Cloud Library for Datastore to the App Engine development server?

We are planning the migration of an internal app running on Google App Engine Standard Environment for Java 8 from the now superseded App Engine APIs to the recommended client library for Cloud Firestore in Datastore Mode, also in order to enable porting to other execution environments.
Besides a host of issues with missing IN/OR query operators, we are also struggling with the setup for local testing: according to Using the Java 8 Local Development Server
The development web server simulates Datastore using a local
file-backed Datastore on your computer. The Datastore is named
local_db.bin, and it is created in your application's WAR directory,
in the WEB-INF /appengine-generated/ directory.
but we have no clue about how to connect Google Cloud Client Library for Datastore to the local emulator.
Defining default credentials with
gcloud auth application-default login
or setting the GOOGLE_APPLICATION_CREDENTIALS environment variable after obtaining the credentials for the service account with something like
gcloud iam service-accounts keys create key.json \
--iam-account=project-id#appspot.gserviceaccount.com
as suggested elsewhere, just results in the client library connecting to the actual cloud server, rather than to the local emulator, as per the ADC policy.
I'd expect the development server to automatically provide connection hints to the client library, but that's apparently not the case.
Any suggestion for setting up a local testing environment, taking into account that we can't just migrate to the standalone Datastore Emulator, as we need other services currently provided only by the App Engine development server (e.g. email submission)?
Edit / After further tinkering we are working around the issue by using both the Local Development Server and the standalone Datastore Emulator as:
gcloud beta emulators datastore start \
—project=project-id \
--host-port=localhost:8081 \
--data-dir=target/war
DATASTORE_EMULATOR_HOST=localhost:8081 java_dev_appserver.sh \
--port=8080 \
target/war
However, the process is quite cumbersome and difficult to automate: what we are looking for is a way to automatically connect Google Client Library to the Datastore Emulator managed by the Java 8 Local Development Server when launching the app with something like the App Engine Maven plugin, e.g. mvn appengine:run.
This GitHub issue was closed with the confirmation that the Datastore Client Library is not compatible with the local Web Server Datastore Emulator.
I actually tried it, to see if was possible to force a connection to the local Web Server. The code below sets a custom builder with the desired host configuration:
DatastoreOptions.Builder builder = DatastoreOptions.newBuilder();
builder.setHost("http://localhost:8080");
builder.setProjectId("<PROJECT_ID>");
Datastore ds = builder.build().getService();
Key key = ds.newKeyFactory().setKind("MyEntity").newKey("mykey");
Entity entity = Entity.newBuilder(key).set("p1", "Hello World!").build();
entity = ds.put(entity);
System.out.println(entity);
entity = ds.get(key);
System.out.println(entity);
After running the local Web Server I noticed a connection was indeed possible, however the Datastore Client Library returned the following error when trying to store new entities:
[INFO] GCLOUD: com.google.cloud.datastore.DatastoreException: Non-protobuf error: <html><head><title>Error 404</title></head>|<body><h2>Error 404</h2></body>|</html>. HTTP status code was 404.
With the following output by the Web Server:
Oct 02, 2019 3:05:59 PM com.google.appengine.tools.development.jetty9.LocalResourceFileServlet doGet
WARNING: No file found for: /v1/projects/<PROJECT_ID>:commit
I believe this adds to the confirmation that the new library is just not compatible to the old emulator.
The workaround you found is probably the best solution while you work/wait on the full migration to the Datastore mode Emulator.

Google App Engine vs Tomcat

I was able to create the basic 'hello world' program.
When I tried to understand the difference between a cloud and a server I learned that Cloud is where you have an access to virtual instance created exclusively for you and you are free to choose and install software of your choice.Why Google App Engine(GAE) is used widely where as tomcat is not used. What are major differences between GAE and Tomcat?
Cloud is Google Cloud Platform at this case. App Engine is just one of their services.
App Engine is a platform to build your apps on top of it. A Platform As A Service or PaaS. It simplifies the process of building a scalable application, and you should use it when you understand what you really need and understand principles of scalable application.
Tomcat is a Java web container, and there're many alternatives. Google App Engine is using Jetty. You could actually use it with Tomcat by using Flexible VM, though it doesn't make much sense.
App Engine is not about web server, it's a set of services that helps you to build a scalable app. It includes Memcache, Datastore, Task Queue, Images API, deployments tools and versioning, CDN for static files, and most important automatic scale.
Actually you aren't limited to App Engine on Google Cloud Platform. There is more traditional service, like own server in the cloud, called Compute Engine. There you can run your Tomcat or anything else.

Deploy Angularjs 1.5.X on JBoss App server

Can Angularjs 1.5.X App directly deployed onto application server like JBoss 6.x. I have deployed Angularjs apps on Nginx, but I was wondering if AngularJS can be deployed to listen on different port on Same App server that also host the Rest API's developed using RestEasy on JBoss.
Does JBoss has ability to run Webapps?
JBoss Application Server (AS) was a product developed by RedHat, currently replaced by Wildfly, which, being a certified implementation of the Java Enterprise Edition specification, allowed the building, deploying, and hosting of highly-transactional Java applications and services.
Therefore, the answer to your question is yes. JBoss AS, as it name states, has the ability to serve web applications.
To deploy your AngularJS application on JBoss, I'd suggest you to create a web project and have it builded and packaged as a ready-to-deploy WAR archive using a build manager such as Maven.
As an example, you can follow the kitchensink-angularjs quickstart provided by JBoss.
Finally, regarding your AngularJS deployed on a different port question, you can find an answer to it in How to run different apps on single JBoss AS 6 instance behind different ports?.

Unable to deploy Eclipse WTP EAR multi-module project to remote instance

I am creating a GAE application, and I am following the proposed structure of modularized GAE applications in Eclipse with WTP, as documented here (see section "Enterprise Application EAR").
I have created and linked a local server instance of GAE, and the deployment of the EAR with its modules to the GAE development instance at localhost works fine.
However, when I try to "Deploy to App Engine" (via the Google button) in order to release my app to the Google remote server, I am stuck with the error "...(EAR project name) is not an App Engine project". I have also tried to define a new server with a remote address, but this fails with the error "The currently selected server type does not support remote hosts". The host name's field is restricted to "localhost" as a valid server address.
My Eclipse project structure looks as follows:
<<Enterprise Application Project>> ear-app
|
-- <<Dynamic Web Project>> app-module-1
-- <<Dynamic Web Project>> app-module-2
-- <<Dynamic Web Project>> app-module-3
-- <<Dynamic Web Project>> app-module-4
Please note that this is not a single "Google / Web Application Project", which works as expected (but does not support modularization with multiple Eclipse projects).
Please also note that I am not using Maven and the proposed mvn commands, as documented here.
I am using the GAE SDK 1.9.3 and GPE 3.5.1 in Eclipse Kepler 4.3.1.
So how do I deploy the Eclipse WTP project structure to Google remote servers? If this is not possible, do you suggest that I switch to Maven, and if so, does this support a multi-module project to be managed from within Eclipse?
Rather by chance, I stumbled across the solution:
In the Servers view, and upon right-click of the local development server, there is another context menu entry "Google App Engine WTP / Deploy to Remote Server". This will deploy the EAR and all modules to the Google infrastructure. There is also a "Google App Engine WTP" button in the Servers view's menu, offering the same options.
Frankly, I find this a highly inconsistent UI implementation: If we create a project of type Google Web Application, then the Google button in the main menu is effective, and the context menus can be found as "Google...". These become invalid (but are still present) when we create a multi-module EAR structure in the WTP style. This will create a different set of buttons and context menu entries, all in different places, and the context menu of the LOCAL server would then support deployment to the REMOTE server.
UPDATE:
After using the GAE tools for a couple of weeks, I finally switched to the command line options (appcfg) for remote deployments. I had additional errors in GPE for deployment rollbacks (which fail in Eclipse but work with appcfg). I recommend appcfg as administration tool for the Google infrastructure, it provides more control and it is more mature than the Eclipse plugin.

Deploy Java Web Application and MySQL database in the cloud

my issue is that I've been developing a Java Web app in Netbeans 7.2, which I've used Hibernate and JSF Facelets to communicate and show the data from a MySQL database deployed in my local server (localhost).
But now, I want to deploy both (my java web app and mysql database) in the cloud in a web server, or something but I don't know even how to start this. I've seen something about Google App Engine, but I didn't get the idea, and many others...
I just need to deploy my app to give access to other people to use my web app.
Google Appengine is a Framework.
its not webserver where you can deploy your app as on your local machine.
what you are looking for is
Amazon EC2
Google ComputeEngine
OpenShift
and others...... (to many to list them all)
most of them are not free.
some like openshift are if you dont need much resources.
there you can install the server you need, (its just like a remote server)
and deploy your app to.

Resources