Archive

Author Archive

Spring Social apps on Google App Engine – *** is a restricted class!!

October 5, 2011 Leave a comment

Building Spring Social applications and deploying them on Google App Engine may often lead you into the following errors:

java.lang.NoClassDefFoundError: javax.net.ssl.KeyManagerFactory is a restricted class. Please see the Google  App Engine developer’s guide for more details.

or

java.lang.NoClassDefFoundError:javax.net.ssl.HttpsURLConnection is a restricted class. Please see the Google  App Engine developer’s guide for more details.

Well, to resolve this, if you cannot use one of the workarounds as mentioned here, you are kind of held up with the fact that Google has a whitelist that enlists the limited set of classes in their Java Runtime Environment.

Unfortunately, during development I figured out that Spring Social (internal libraries/artifacts) uses a number of classes that are out of that list, and would either have to be requested (to Google) to be added or choose a different application hosting mechanism.

Categories: Social

Building scalable Java based Facebook apps for FREE!

October 1, 2011 Leave a comment

Looking to create a Java-based Facebook app, and need the easiest steps to build and host one? without the (cost) overheads of hosting it ? Read on…

Note that this also covers how to create a Facebook app using the new (latest) App creation interface given by Facebook.

In a nutshell, we will be building our application using Eclipse (+ Google Plugin for Eclipse + Facebook SDKs). The app will be created as a Google App Engine Project (so that we can deploy it on Google App Engine, leveraging the all goodness of the platform – scalability being one of major ones!).

Ok, so here we go. Here are a few simple steps that will get you going in building your Facebook app and hosting it for free in no time.

Step 1:

Download Eclipse, if you do not already have one. Preferably, Eclipse Galileo. You may also use SpringSource Tools Suite as the IDE, since it has great support for building Spring based applications. Once you have your IDE up and running, install the Google Plugin which will allow you to smoothly create Google App Engine projects and deploy them to App directly from your IDE.

Step 2:

Download the Facebook Java SDK, which we will use for building our Java-based Facebook app.

Step 3:

Once you have completed the above steps, create a Google App Engine project in your IDE, by clicking New -> Project… -> Google -> Web Application Project.

Give the project a name, a package, and ensure that you deselect the “Use Google Web Toolkit” and “Generate project sample code” options. Here’s how your window should look like:

 

 

 

 

 

 

 

 

 

 

 

 

Here’s how your IDE wokbench looks like when you click Finish.

 

 

 

 

 

 

 

Step 4:

Now Copy the Facebook SDK libraries (downloaded in Step 2) into the war/WEB-INF/lib folder of your project, and then add these libraries to your project’s classpath. Here’s how your project should look like after this:

 

 

 

 

 

 

 

 

 

 

 

 

Step 5:

Now, this step involves a number of codes changes, from changing the default servlet to the code that captures Facebook authentication, to designing and forwarding to your desired application’s view (JSP). Instead of walking through individual steps, here’s the sample project which you can use to get started right away. Add/remove code to suit your application needs.

Step 6:

Now is the time to create your Facebook app.

1. Goto https://developers.facebook.com/apps and click the “Create New App” button

2. Enter your App’s display name , say MyAppOnGAE, and give a namespace, say myappgae. Accept the terms and click Continue.

 

 

 

 

 

3. Your app would now be created and you will be taken to your app’s Settings page:

 

 

 

 

 

 

 

 

 

4. Note down your App ID and App Secret. Copy these into the web.xml file of your project under (war/WB-INF/web.xml), since it contains the configuration to set your App’s API key and Secret key.

 

 

 

 

 

5. You are now ready to upload the project to Google App  Engine.

6. Once successfully done, and if you used the project I have setup in Step 5, your application URL would be http://helloworld.appspot.com/testapplication, where helloworld is the name of your application that you create on Google App Engine (and could be different, based on what name you choose).

7.  Now go back to your Facebook App’s settings, and we will “Select how your app integrates with Facebook”. So, click on the link “App on Facebook” and enter the Canvas URL as follows:

 

 

 

 

 

 

 

8. Click Save Changes, and your app would be ready to use @ http://apps.facebook.com/myappgae

The above simply displays a Hello World! message as the Facebook app, but feel free to modify the application as per your needs, which should now be a standard web application development deal.

Enjoy!!

Spring Social – Building Social apps

October 1, 2011 Leave a comment

For all you people trying to get started with building your own uber-cool Social apps (connecting with Facebook, Twitter,  LinkedIn, TripIt, etc.), Spring Social comes to your rescue!

After trying out a variety of tools and SDKs for building social applications, I have found this to be the best one to get yourself started within minutes, especially when combined with SpringSource Tools Suite, which provides a convenient development environment to build your applications. The project also comes with a set of ready-to-go samples and showcase, so that you get a clear picture of how to integrate with the most popular social networking websites of today.

So, get started now!!

Categories: Social Tags:

Sort 10GB dataset over 1GB memory

October 1, 2011 Leave a comment

This is a frequently encountered problem, the solution to which is based on the concept of External Sorting.

Here’s a summary of the process involved in doing this:

  1. Of course, given that you only have 1 GB of main memory, that’s what you can read at once at any given time. So, read data in chunks of 1 GB at a time and sort using on of the conventional sorting algorithms, most likely Quicksort.
  2. Write each sorted dataset to disk (of course, assuming that you have enough disk space :)).
  3. You will end up having 10 chunks of 1 GB (10GB/1GB = 10 chunks), individually sorted, datasets which now needs to be merged into one single output file (on disk).
  4. Now read the first 100 MB (= 1 GB /10 chunks) of each sorted chunk into an input buffer in main memory and allocate the remaining to an output buffer.
  5. Perform a 10-way merge and store the results in the output buffer. If, at any given time, the output buffer is full, write it to the final sorted file, and empty it. If any of the 10 input buffers gets empty, fill it with the next 100 MB of its associated 1 GB sorted chunk until no more data from the chunk is available. This is the key step that makes external merge sort work externally — because the merge algorithm only makes one pass sequentially through each of the chunks, each chunk does not have to be loaded completely; rather, sequential parts of the chunk can be loaded as needed.
<Inspired from Wikipedia>
Categories: Tech Trivia Tags: ,