neděle 4. března 2012

Making GAE app run on Tomcat

Today I'll tell you how to run your Google App Engine Java application on Tomcat server.

The situation:
You made yourself Google App Engine (GAE) project in Eclipse using Google's plugin. You can now run it locally from Eclipse or deploy it to Google to run it online. But what if you want to run it somewhere else, perhaps in your own Tomcat server?

If you don't use Google's specific API in you app, you can very easily run you GAE/GWT app in other servlet container such as Jetty or Tomcat. I am going to focus on Tomcat.

Method 1:
If you just want to deploy your app on Tomcat once a while, you can grab war folder from your project and copy it into Tomcat's webapps directory. Restart Tomcat and it should load the app automatically.

But when you developing an application and deploying it to your Tomcat server repeatedly you wouldn't like to manually copy war folder with every change in source code right?

Method 2:
Fortunately you can make Eclipse to do it for you. You just have to transform your GAE project into faceted form:
  1. In Eclipse - right click your project root folder. Choose Configure -> Convert to Faceted Form.
  2. Tick Dynamic Web Module and on the card Runtimes tick Apache Tomcat.
  3. Click Further configuration available....
  4. Write war into Content directory.
  5. Click OK.
  6. Click OK. Eclipse then convert your project and after that you can right click your project, choose Run As -> Run on Server and enjoy the autobuild and deploy on Tomcat.
Of course mentioned recipe suppose that you know how to install and set Tomcat and how to add it into Eclipse.

Žádné komentáře:

Okomentovat