Our appengine application consists of several microservices deployed in a mix of standard and flex environments. Since we are using both flex and standard we chose jerse to implement our backend services as endpoint framework does not work with flex. We are not able to make this combination of Jersey + Appengine Standard + Endpoint work. When we deploy the swagger using gcloud cloud manager, it does not link with the backend services.
I could not find any documentation regarding how to integrate App engine standard and endpoint without using endpoint framework annotations.
Has anybody implemented the rest service backends using the combination
Jersey + App engine Standard + Cloud Endpoints. Is it possible to integrate Cloud endpoints and appengine standard without using endpoint framework annotations.
Pls note : We have tested Jersey + Flex + Endpoints and it works.
This is not tested or documented, so you are playing in a new area. It should work, and I'm happy to try and help you debug it. To use Endpoints on Standard with Flex, you have to do this:
Including this dependency:
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine-all</artifactId>
<version>${endpoints.management.version}</version>
</dependency>
Add this configuration to your web.xml, then add a filter-mapping to go in front of jersey:
<filter>
<filter-name>endpoints-api-controller</filter-name>
<filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
<init-param>
<param-name>endpoints.projectId</param-name>
<param-value>${endpoints.project.id}</param-value>
</init-param>
<init-param>
<param-name>endpoints.serviceName</param-name>
<param-value>echo-api.endpoints.${endpoints.project.id}.cloud.goog</param-value>
</init-param>
</filter>
Upload your OpenAPI specification using gcloud service-management deploy.
In appengine-web.xml, add an environment variable definition:
<env-variables>
<env-var name="ENDPOINTS_SERVICE_NAME" value="echo-api.endpoints.${endpoints.project.id}.cloud.goog" />
</env-variables>
Related
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.
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.
we would like to improve build configuration/integration of Java + JavaScript projects.
back-end : Java app, Spring framework, REST API + maven as build tool
front-end : HTML + CSS + JavaScript, (based on ng-boilerplate project template - it separates nicely all modules,services,directives,shared assets) and it's using few JavaScript tools like npm, Bower, Karma + Grunt
Workspace configuration is pretty simple - each project in separate directory :
/workspace
/JavaBackend
/JsFrontend
Problem is that developers are dealing with “Origin null is not allowed by Access-Control-Allow-Origin" messages in browsers as they run AJAX queries from front-end (from file://..../JSApp/build/index.hml) and Java App server is on localhost:8080. We could switch browser security off or modify headers to allow cross origin requests but we think it's not good way how to achieve that.
We don't want to have JS resources inside of Java project in /src/main/webapps/ as in production environment apps will be deployed on different machines and each app has it's own build server.
Do you have experience with similar project configuration ? What would you recommend to us ?
Meanwhile we will experiment with Tomcat 7 to check if it can e.g. serve external static resources (js stuff) out of context of java app
For development purposes, I would let Tomcat include the front-end folder in the server.xml by means of a <Context> tag. The folder can be arbitrary and even in another repository (e.g. /GitRepos/ApplicationGui/app).
...
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
<Context docBase="/workspace/JsFrontend" path="/"/>
<Context docBase="FlexibleOrders" path="/FlexibleOrders" reloadable="true" source="org.eclipse.jst.j2ee.server:FlexibleOrders"/>
</Host>
</Engine>
</Service>
</Server>
In production, I would recommend to make a Maven artefact out of the front-end. It can be then included via dependency in the backend like this:
<dependency>
<groupId>org.enterprise</groupId>
<artifactId>application-gui</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
See this blog for a complete configuration for production:
http://wiki.switajski.de/2016/01/24/how-to-create-maven-artifact-with-static-web-resources.html
I know there's WSGI middleware for django, but I can't find anything for webapp2. Would the django middleware work?
To get the same behavior that django provides with webapp2, you only need to add the following header to the response:
self.response.headers["X-Frame-Options"] = "SAMEORIGIN"
https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
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.