Tic Tac Toe using Rails and Grails on GlassFish v3

GlassFish v3 is a modular (OSGi compliant), embeddable (runs in-VM) and extensible (hosts non-Java applications) Application Server. The "extensible" part was demonstrated during JavaOne 2008 by deploying Rails, Grails and Django sample application on GlassFish v3 Technology Preview 2. This blog announces the availability of Rails, Grails and (of course!) Java EE version of the demo code.

The sample application is a simple multi-player game that can be played on Internet and deployed on GlassFish. One of the simplest multi-player game is Tic-Tac-Toe. The complete instructions to checkout, build, deploy and run the sample are available here. The demo can certainly be improved by using the best practices from Rails and Grails and I'll work on them in next few days.

The demo is played in 2 different browser windows (tested on Firefox, Safari & IE). The clicks in the grid on one browser are displayed on the other browser (propagated using GlassFish Comet) and row and column winners are shown.

Some points highlighted by the demo are:
  • GlassFish v3 supports deployment of Rails and Grails applications, in addition to traditional Java EE apps.
  • GlassFish v3 has a completely modular architecture as evident by the pluggability of JRuby/Rails.
  • Features of the underlying GlassFish runtime can be accessed.
    • Any click in the grid is pushed to the endpoint and then propagated to all the clients using GlassFish Comet. So effectively, now you can build Comet-enabled applications using Rails and Grails.
    • Rails application is deployed as a composite application where Serlvet is bundled with the application and accessed from the View.
Check out the demo now!

You can learn about the support of different Dynamic Languages on GlassFish on glassfish-scripting.dev.java.net. Send us feedback on webtier@glassfish.dev.java.net or GlassFish WebTier Forum.

Technorati: conf javaone javaone08 jruby ruby rubyonrails grails javee glassfish v3 netbeans

[Trackback] GlassFish v3 is a modular (OSGi compliant), embeddable (runs in-VM) and extensible (supports non-Java apps) Application Server. The extensible part is demonstrated by deployment of Rails and Grails applications. An example of embeddability is an in-VM...

Posted by Arun Gupta's Blog on June 25, 2008 at 11:17 PM PDT #

[Trackback] I presented on GlassFish at Utah JUG yesterday, slides are available. The topic provided insight into GlassFish v2, the current production version, and GlassFish v3 - the upcoming modular, embeddable & extensible version. There were close...

Posted by Arun Gupta's Blog on July 18, 2008 at 12:11 AM PDT #

[Trackback] Last day of Rails Conf Europe 2008 (Day 1 & Day 2), and it's finally over! David Black's opening session talked about Ruby and Rails Symposium: Versions, Implementations, and the Future. Here is a brief summary of MRI Ruby...

Posted by Arun Gupta's Blog on September 05, 2008 at 03:19 PM PDT #

[Trackback] Mauricio, Doris, Simon and I visited DFJUG @ Taguatinga yesterday (make sure to pronounce it correctly, otherwise you'll be corrected again & again, as I was :). 200 attendees, mostly students, stayed all along the 4 hourof  present...

Posted by Arun Gupta's Blog on September 24, 2008 at 10:11 PM PDT #

[Trackback] Jim and I presented on "Using Comet to create a Two-Player Web Game" at Ajax World 2008 West yesterday. The talk explained the basic concepts of Comet, showed how a Tic Tac Toe game can be easily created using...

Posted by Arun Gupta's Blog on October 21, 2008 at 04:07 AM PDT #

[Trackback] This sounds like an interesting demo. Sun has GlassFish playing two-player Tic Tac Toe over the Internet in a browser.

Posted by All the Way to the Beginning on October 23, 2008 at 03:56 AM PDT #

[Trackback] 1400 registrations, 112 sessions, free pizza, a barbecue on Saturday night, raffles and lot more - that is Silicon Valley Code Camp. Jitu, Jiandong, Jacob, and I presented on GlassFish at Silicon Valley Code Camp over the weekend. The...

Posted by Arun Gupta's Blog on November 10, 2008 at 08:32 PM PST #

Good Morning Mr Gupta,
I am a spanish electrical engineering student and I am very interested in your post about the tic tac toe game.
I did a tic tac toe using javascript and I would like to make it multiuser using Ruby on Rails but Im not quite sure how to start...I tried to check out your code but when I introduce my java.net id it said "item not found" could you please help me.
Thank you very much.

Posted by Ernie on December 11, 2008 at 05:00 PM PST #


Can you provide the exact commands you are using to check out the code ?

Posted by Arun Gupta on January 08, 2009 at 08:12 AM PST #

Good morning Mr Gupta,
I tried again this morning and everything was ok. I hope I can understand the code...
Thank you very much.

Posted by Ernesto on January 08, 2009 at 03:25 PM PST #

Ernesto, that's great!

I meant to update the code next week so that it works with Rails 2.x and some other improvements. Will keep the blog updated.

Posted by Arun Gupta on January 08, 2009 at 10:34 PM PST #

Hi Arun,

Did you update Tic Tac Toe demo ?

I'm interested to use it with Rails 2.3.2 and maybe refactor it to use jquery plugin's Comet


Posted by Babar on May 28, 2009 at 07:14 PM PDT #

Babar, have not updated the demo with Rails 2.3.2. Would you like to help ?

Posted by Arun Gupta on May 29, 2009 at 11:07 AM PDT #

I think I'll have time to do that this summer.

Posted by Babar on June 10, 2009 at 10:55 PM PDT #

Babar, Let me know when you are ready and I'll get you signed up.

Posted by Arun Gupta on June 10, 2009 at 11:00 PM PDT #

Post a Comment:
Comments are closed for this entry.

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« April 2014