CS6320:  SW Engineering of Web Based Systems

 

Google App Engine: Eclipse Plugin

 

1) Create Project (File->New->Web Application Project OR File->New->Other->Google->Web Application Project)

creating new web app project

 

The result will be the following pop-up window

specifiy web app
You need to give

          • Project Name
          • Package (come up with a good naming structure for yourself...I use grewe.applicationDomain.projectname or whatever)
          • place it where you want
          • Make sure you DO NOT select GWT
          • Make sure you DO select Google App Engine, this is where you can also specify the SDK version you want

           

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The result will be a directory structure like the following

Note: we have created a project called "OpenCVBackendJava"

  • package = grewe.ilab.vision

  • src has the created servlet = OpenCVVancendJavaServlet.java

  • war/WEB-INF/web.xml and apengine-web.xml = the xml configuration files



 

 

web.xml file that was autogenerated- can edit in design or source

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>OpenCVBackendJava</servlet-name>
<servlet-class>grewe.ilab.vision.OpenCVBackendJavaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>OpenCVBackendJava</servlet-name>
<url-pattern>/opencvbackendjava</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

appengine-web.xml file that was autogenerated

basically this says we are runing an application named opencv-backend-test
and it is version 1 of this application. This is where you can also control behaviors
like static files and sessions (see Chapter 3 of book and later materials)

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>opencv-backend-test</application>
<version>1</version>

<!--
Allows App Engine to send multiple requests to one instance in parallel:
-->
<threadsafe>true</threadsafe>

<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

<!--
HTTP Sessions are disabled by default. To enable HTTP sessions specify:

<sessions-enabled>true</sessions-enabled>

It's possible to reduce request latency by configuring your application to
asynchronously write HTTP session data to the datastore:

<async-session-persistence enabled="true" />

With this feature enabled, there is a very small chance your app will see
stale session data. For details, see
https://cloud.google.com/appengine/docs/java/config/appconfig#Java_appengine_web_xml_Enabling_sessions
-->

</appengine-web-app>

OpenCVBackendJavaServlet.java auotogenerated file

 

package grewe.ilab.vision;
import java.io.IOException;
import javax.servlet.http.*;
@SuppressWarnings("serial")
     public class OpenCVBackendJavaServlet extends HttpServlet {
         public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         resp.setContentType("text/plain");
         resp.getWriter().println("Hello, world");
     }
 }
           

 

 

 

 

2) Edit Code in Project, create new classes,etc. as desired

 

 

3) Run the Project locally (right_click project folder->Run as ->Web Application (can also do Debug As)


google app engine run as web app

Will start the webapp locally at either http://localhost:8080 or http://localhost:8888

 

 

 


OLD WARNING App Engine does not yet support Java 8. You can build with version 8 of the JDK locally if and only if you set the Compiler compliance level for your project to Java 1.7. You cannot deploy an application that requires Java 8 to App Engine. see Google App Engine documentation for latest details READ HERE FOR HOW TO CHANGE TO 1.7 (you must have it installed)

© Lynne Grewe