Production deployment issue on Google App engine - google-app-engine

I am using Google App engine and deployed web application.
I tried to deploy code on local using App engine then it is working fine
but when I deployed on Production server then it caused error.
Request : POST 20180909t164211-dot-spry-autumn-140509.appspot.com/_ah/spi/BackendService.getApiConfigs
(View request) Status : 500 Internal Server Error, Updated Screen shots for error and web.xml configration.
Web.xml configration:
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value />
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
Production error :
Please suggest me some solutions for same.

Endpoints v1 has been shut down. You must migrate your application to Endpoints v2. See migration instructions.

Related

Migrating to Cloud Endpoints 2.0 - Working on localhost but not on App Engine

I'm migration my GAE Java app to Google Cloud Endpoints 2.0. I followed the migration guide (https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating) to migrate to Endpoints v2.0.
The endpoints service calls are working on localhost but returning 404 (Not Found) when uploaded to the App Engine. I'm using Guice.
The relevant section from my web.xml looks similar to this:
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.xyz.myapp.server.guice.MyAppGuiceServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>EndpointsServlet</servlet-name>
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.xyz.myapp.server.endpoints.MyEP1,com.xyz.myapp.server.endpoints.MyEP2</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>EndpointsServlet</servlet-name>
<url-pattern>/_ah/api/*</url-pattern>
</servlet-mapping>
MyAppGuiceServletContextListener.java
public class MyAppGuiceServletContextListener extends GuiceServletContextListener {
#Override
protected Injector getInjector() {
return Guice.createInjector(new GuiceServletModule(), new EPServletModule());
}
}
EPServletModule.java
public class EPServletModule extends EndpointsModule {
#Override
protected void configureServlets() {
super.configureServlets();
Set<Class<?>> serviceClasses = new HashSet<Class<?>>();
serviceClasses.add(MyEP1.class);
serviceClasses.add(MyEP2.class);
configureEndpoints("/_ah/api/*", serviceClasses);
}
}
GuiceServletModule:
public class GuiceServletModule extends ServletModule {
#Override
protected void configureServlets() {
super.configureServlets();
serve("/myapp/servlet1").with(Servlet1.class);
serve("/myapp/servlet2").with(Servlet2.class);
}
}
I'm able to invoke the regular servlets at the paths:
https://[version]-dot-myapp-id.appspot.com/myapp/servlet1
https://[version]-dot-myapp-id.appspot.com/myapp/servlet2
But I'm not able to access the endpoints. It always returns 404 error code. I tried via my Javascript client and also via the APIs Explorer, and get the same error.
I also checked the logs and strangely the logs show the POST request like this:
"POST /_ah/spi/com.xyz.myapp.server.endpoints.MyEP1.myEPMethod HTTP/1.1" 404
Why does it start with /_ah/spi/ when my client is invoking it via /_ah/api/ ?
NOTE: I'm able to invoke the Endpoints 1.0, which are deployed on a different version of the same app, without any issue. But the Endpoints 2.0 version is not working.
Am I missing something?
I also have a very basic question. My client is Javascript based. Does it really make use of the Discovery Document?
I fixed this by Updating Android Studio to the latest version and updating the SDK.

How do I configure Java EE running on GAE to work with Angular UI Router in html5Mode?

I am attempting to set the UI Router location provider html5Mode to true for my Angular application: locationProvider.html5Mode(true). While this works client side (appropriately redirects) I am running into issues server side. I am running an instance Java Enterprise Edition on Google App Engine.
I have configured my web.xml as outlined for Java EE section in the Angular ui-router FAQ:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>
<!-- stuff specific to my GAE app -->
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Sadly even with the above configuration when I browse to client based routes I am still receiving a 404 error from the server. I have tried various values (/index.html, index.html) for the error-page > location element with the same result.
I am probably missing something obvious in my configuration, but am at a loss to what I am doing wrong.

Invoking JSP inside Google App Engine application results in 404 error on production server, works on development server

I am running into a problem with invoking JSP files inside a Google App Engine application. Here is an equivalent version of the relevant configuration in web.xml:
<servlet>
<servlet-name>SomeServlet</servlet-name>
<jsp-file>SomeServlet.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>SomeServlet</servlet-name>
<url-pattern>/prefix</url-pattern>
</servlet-mapping>
When I try accessing SomeServletin the development environment at http://localhost:8888/prefixthis works fine, however if I try it in production at http://someapp.appspot.com/prefix I get HTTP error 404 (Not Found). It's war/SomeServlet.jsp in the file system. There is no further information in the server logs. I have also tried various access control configurations but to no avail.
What could be the reason for this failure?
You should use:
<jsp-file>/SomeServlet.jsp</jsp-file>
From the documentation:
Note: The <jsp-file> must start with a forward slash (/) if the JSP is
in the application's root directory.

Jersey 2.3.1 on Google App Engine

I wonder if last version of Jersey does have support of Google App Engine.
I have found 'gae-integration' project (https://github.com/jersey/jersey/tree/master/incubator/gae-integration) with a link to Jersey 2.3.1. Actually all my attempts failed but maybe someone was luckier?
Thanks in advance!
I struggled to get Jersey 2 to work with GAE but figured it out now.
Tested OK with GAE SDK 1.9.10 and Jersey 2.12, including multipart/form-data. See for instance this blog article.
In Jersey 2 you have to enable features in your web.xml which is automatically enabled in Jersey 1. For example the snippet below enables JSP page support and the multipart/form-data MIME type features. (I don't think the GaeFeature is required, but haven't tested without it).
<servlet>
<servlet-name>com.namibiaonthenet.www</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.namibiaonthenet.www</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>
org.glassfish.jersey.server.mvc.jsp.JspMvcFeature;
org.glassfish.jersey.server.gae.GaeFeature;
org.glassfish.jersey.media.multipart.MultiPartFeature;
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
To enable the multipart/form-data feature an additional short config. file is required in your project - for details see my and #yves' answers here.
If you still struggle, let me know in a comment to this answer.

Servlet works on debug mode but fails to work when deployed to AppEngine (Appspot)

I have a gwt application that have some servlet on it. During development mode, the servlet can be accessed properly but when deployed I can't access it like:
Debug mode:
http://127.0.0.1:8888/mygwtapp/greet (Works)
Deployed in Appspot.com
http://mygwtapp123456.appspot.com/mygwtapp/greet (Does not work)
What could be the problem?
Here's the mapping on the web.xml
<servlet>
<servlet-name>greet</servlet-name>
<servlet-class>com.mygwtapp.server.GreetServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greet</servlet-name>
<url-pattern>/mygwtapp/greet</url-pattern>
</servlet-mapping>
Why aren't you using http://mygwtapp123456.appspot.com/mygwtapp/greet when deployed, when this is what you mapped in your web.xml?
Are you sure you've updated your default version in appengine control panel? If you updated version id in appengine-web.xml, but haven't set that as default, your appspot could be serving a web.xml that doesn't have your updated servlet.
If this is not the issue, please respond with any additional logging / error messages you encounter.

Resources