Welcome

Welcome to our blog about all kind of topics that are related to software development. We blog about:

SOA, BPM, EDA, ECM and all the other buzz words. Beware some post might not be so common as you think. We are not scared to go against main stream thoughts.

Technologies like java, maven, springframework, OSGi and front end technologies and frameworks like jQuery, DWR, Flex.

Finally to make this happen we need tools and of course a Mac (well some of us do). So we blog about that as well.

Archives

Java on Google app engine with intelliJ

appengine-silver-120x30.gifThis is a short post about the new java support for google appengine. The Basic steps are described very well at google, check the getting started manual. Here I just describe my experiences with my first java based application for google appengine. I concentrate on the usage of intellij. In coming posts I will create the same application as the one I used for my previous post: using google appengine.


Quick intro

For an eclipse user there are other steps to get things done. There is something like a plugin that might work depending on other plugins that you have installed and some eclipse magic. Sorry, I am a non believer. I prefer another IDE.

So for the non eclipse guys you need to download a zip file with all the resources you need to start working with the new sdk. I create a symbolic link to the downloaded version, that way it is easy to change for future releases.

ln -s appengine-java-sdk-1.2.0/ appengine-java-sdk

As the getting started suggest, you can now test your infrastructure with one of the provided demo’s.

./appengine-java-sdk/bin/dev_appserver.sh appengine-java-sdk/demos/guestbook/war/

Open your browser and go to the link http://localhost:8080/. You should see the following screen.

Screendump_google_demoapp.png

Oke, time to take the next step. The structure for an application is the same as for a web archive. There is a catch, you cannot use the war file itself, you need the exploded directory. Luckily it is very easy to do this with maven or with Intellij. Those eclipse users that are still reading this post have an easier life. They can use the wizard from the google plugin. I start off with a normal intellij java project with a web facet.

Google app engine works with servlets, so we need to create a servlet, we also need to add this servlet to the web.xml. Since the code I used is at the google tutorial, I’ll not repeat it here.

Google appengine needs an additional xml configuration file. This file is called and it looks like this:

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

Next step in intelliJ is to make the module, you can find the exploded war in the folder out > exploded > GoogleAppEngineGuestbookWeb. Using this exploded folder you can start the appengine. We need a runner in intellij. This is not very hard to do.There are two important steps. The first step is to create a library that you add to your module. This library contains one jar file : appengine-tools-api.jar. You can find this jar in the distribution of google appengine you downloaded. If you do not know how to add a library, open the module settings (apple: command + ;). Create a new library and when asked say yes to add it to your module. The screen should look like the following image.

Intellij_configure_library.png

Next up is configuring a runner. Create a runner of type Application. Now use the script dev_appserver.sh, that you can find in the distribution of google appengine in the bin folder. We need to set the environment variables, the program parameters and the main class.

Main class

com.google.appengine.tools.KickStart

Program parameters


com.google.appengine.tools.development.DevAppServerMain
out/exploded/GoogleAppEngineGuestbookWeb

Check the second parameter, this is the location of the exploded war file that intellij creates for you.

Environment variables


SDK_LIB=YOUR_GOOGLE_APPENGINE_HOME/appengine-java-sdk/lib
SDK_CONFIG=YOUR_GOOGLE_APPENGINE_HOME/appengine-java-sdk/config/sdk

The screen for configuring your runner now looks like this

Intellij_configure_runner.png

That is about it, now you can run the application. After running, the output in the console is:


2009-04-08 23:53:44.332 java[3557:10b] [Java CocoaComponent compatibility mode]: Enabled
2009-04-08 23:53:44.333 java[3557:10b] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
The server is running at http://localhost:8080/

Now you can point your browser to the following url : http://localhost:8080/guestbook and Hello world should be yours.

Deployment

Before you can upload, you need to register yourself with google. If you already have an appengine account, you can request the java beta admittance. After that create a new google appengine application in your domain. That’s it, remember the name of the app you just registered because you need it in the next step.

Next up is the actual deployment, this is not a very complicated process. You can use the same directory that you use for the test server. Be sure to change the file appengine-web.xml. Add your name of the application to the application tag. If your using intellij do not forget to make the module. In my case this application name is doingjava. Now all you need during the upload is your google account name and password. Next is the command to do the actual upload


./appengine-java-sdk/bin/appcfg.sh update PATH_TO_YOUR_INTELLIJAPP/out/exploded/GoogleAppEngineGuestbookWeb

In my case you can check if it works on the following url: http://doingjava.appspot.com/guestbook.

Conclusion

This is not a conclusion on the usage of google appengine and java. For me it was an exercise to create a project in intellij and be able to use the google mock webapp runner. This seems to work nicely. The future will bring more posts about google appengine which now support java.

I do want to stress this is not a best practice, I advise to use an ant script that you can get from google at the following url. http://code.google.com/appengine/docs/java/tools/ant.html

Some important url’s

8 comments to Java on Google app engine with intelliJ

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>