12.2. GWT OpenShift Project

Project fins developed so far is configured for App Engine and there are two options to deploy its code on OpenShift.

  • create a new project and import the code.

  • modify the existing project.

As we are exploring the functionalities of OpenShift with a demo application, we suggest you to go with a new project. For a live project, we suggest the second one.

Create a new project

In this method, we create a new project and import the fins.

Use New Web Application wizard to create new project. Choose GDT PulldownNew Web Application Project … or FileNewWeb Application Project and fill details

Project Name - project name may be anything

Package - in.fins

Use Google Web Toolkit - select

Use Google App Engine - deselect

Google App Marketplace - deselect

Generate Sample Code - deselect

Project name may be anything but package name should be in.fins.

Next import full-code or sec-backends from part-3.zip as explained in Import Code in Chapter 5 - Model.

Copy gwt-visualization-1.1.2.jar from Project fins - war/WEB-INF/lib to new project war/WEB-INF/lib directory and add the jar to project build path.

In case you are using IvyDE, add ivy.xml as Ivy library

In case your are not using IvyDE, copy jars from Project fins - war/WEB-INF/lib to new project war/WEB-INF/lib directory and add the jars to project build path. To connect to MySQL fins need MySQL connector so add mysql-connector-java-5.1.25.jar to project lib directory and build path.

Modify the existing project

Another method is to modify the existing fins project and remove/modify App Engine specific items. Steps to do so are

  • go to the project context menu and choose Build PathConfigure Build Path and in Java Build Path dialog select Libraries tab and remove App Engine SDK entry.

  • next in project’s context menu, choose GoogleApp Engine Settings . . . and in App Engine dialog, deselect Use Google App Engine checkbox.

  • remove all App Engine related jars from war/WEB-INF/lib, which were added by GPE when App Engine support was enabled.

  • add DataNucleus, Hibernate and MyBatis related jars as explained in Persist

  • remove SystemServiceServlet entry and hash out GaePersistTask entry from war/WEB-INF/web.xml.

  • modify src/META-INF/jdoconfig.xml and change datastore config to a RDBMS like HSQLDB. Modify src/in/fins/shared/package.jdo and set value-strategy attribute of Data and DataGroup to uuid-string. Make sure that DataNucleus support is enabled for the project and classes are enhanced.

    Remember to remove DataNucleus support when reverting back to App Engine as App Engine enhances class automatically on each build.

  • if app uses Hibernate as ORM, then modify src/META-INF/fins.properties and set ORM to Hibernate. It also requires an additional validator library hibernate-validator ( same major version as hibernate-core) and also slf4j-api and slf4j-log4j . It’s important to note that while moving back to App Engine you have to remove hibernate-validator and slf4j libraries else GAE raises some weird exception. (this applies only when you use Hibernate as ORM. For OpenShift, we are going with JDO with MySQL as RDBMS)

  • To connect to MySQL, fins need MySQL connector, so add mysql-connector-java-5.1.25.jar to war/WEB-INF/lib and add the jar to build path.

 
 

As App Engine related libraries are removed from lib you will have error in in.fins.server.cache.GaeCache and in.fins.server.task.GaePersistTask classes, but these error will not stop the app from running on an App Server.

Back to GAE

Anytime you want to revert the project back to Google App Engine, reverse the above mentioned steps.

In the next section, we explain the configuration changes required in the project (either the new one or the existing project) to run it on OpenShift.