In the previous post we deployed the sample HelloWorld lift app on tomcat. In this post we will take one step further and go ahead with our lift helloworld webapp and deploy it on Google App engine.
From whatever I have read on different blogs, lift framework 1.0 support seems unavailable on GAE. But in milestone 1.1 there seems to be a limited support for it. With the future release lift may become fully compatible with GAE.
From whatever I have read on different blogs, lift framework 1.0 support seems unavailable on GAE. But in milestone 1.1 there seems to be a limited support for it. With the future release lift may become fully compatible with GAE.
So for this example we will deviate from our 1.0 version to 1.1-M4 version.
Ok, lets get started; first go to your workspace and type in the following maven command
mvn archetype:generate -U \-DarchetypeGroupId=net.liftweb \-DarchetypeArtifactId=lift-archetype-blank \-DarchetypeVersion=1.1-M4 \-DremoteRepositories=http://scala-tools.org/repo-releases \-DgroupId=demo.helloworld \-DartifactId=helloworld \-Dversion=1.0-SNAPSHOT
Once executed it will dispaly a list of outputs in verbose mode. At one or two places you may be prompted, just press enter.
Go to the project directory.
suresh-sharmas-macbook-pro:Projects sureshsharma$ cd helloworld
suresh-sharmas-macbook-pro:helloworld sureshsharma$ ls
pom.xml src
suresh-sharmas-macbook-pro:helloworld sureshsharma$
Packaging of the scr code to the war file can be done with maven's package command. Staying at /Projects/helloworld/ folder give the following command
suresh-sharmas-macbook-pro:helloworld sureshsharma$mvn package
This will create a war file in /Projects/helloworld/target/helloworld-1.0-SNAPSHOT.war
To deploy the war locally, go to the helloworld project directory. Maven comes in with inbuilt jetty and tomcat plugin so give the following command for tomcat deploy the app using tomcat plugin for maven.
suresh-sharmas-macbook-pro:helloworld sureshsharma$ mvn tomcat:run
Ok now coming back to GAE deployment, the first step for Deployment of war file to GAE is to install the google app engine SDK for java. You can download it from here.
Unzip the files in a folder say /usr/local/appengine-java-sdk-1.2.5/
Now for preparing the war file to be deployed in GAE, first go to /Projects/helloworld/src/main/webapp/WEB-INF folder. Their you will see web.xml file. For GAE deployment we need to create another appengine-web.xml file and add the following entries in it.
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>surylifting</application>
<version>3</version>
<system-properties>
<property name="in.gae.j" value="true" />
</system-properties>
<sessions-enabled>true</sessions-enabled>
<static-files>
<exclude path="/**" />
</static-files>
</appengine-web-app>
Change application name with the name of your registered application id in GAE, in my case it is surylifting.
Now first we will deploy GAE locally and then if everything goes fine we will deploy it to GAE.
Staying at /Projects/helloworld/ give the following command
suresh-sharmas-macbook-pro:helloworld sureshsharma$/usr/local/appengine-java-sdk-1.2.5/bin/dev_appserver.sh /Projects/helloworld/target/helloworld-1.0-SNAPSHOT
Note that .war extension is not present above for helloworld-1.0-SNAPSHOT
And here u go u will be able to see it running at http://localhost:8080/
Staying at /Projects/helloworld/ give the following command
suresh-sharmas-macbook-pro:helloworld sureshsharma$/usr/local/appengine-java-sdk-1.2.5/bin/dev_appserver.sh /Projects/helloworld/target/helloworld-1.0-SNAPSHOT
Note that .war extension is not present above for helloworld-1.0-SNAPSHOT
And here u go u will be able to see it running at http://localhost:8080/
Now finally to deploy this app on GAE give the following command
suresh-sharmas-macbook-pro:helloworld sureshsharma$/usr/local/appengine-java-sdk-1.2.5/bin/appcfg.sh update /Projects/helloworld/target/helloworld-1.0-SNAPSHOT
again note that helloworld-1.0-SNAPSHOT is without .war extension
Once the deployment starts you will be prompted for email id and password with which you registered on app engine. Once deployment is done you are ready to see you helloworld app on GAE.
Click on the http://surylifting.appspot.com and you will see my application deployed there. Simple :-)
No comments:
Post a Comment