Miles to go ...

Arun Gupta is a Technology Evangelist for Web Services and Web 2.0 Apps at Sun. He was the spec lead for APIs in the Java platform, committer in multiple Open Source projects, participated in standard bodies and contributed to Java EE and SE releases.
Main | Next page »

http://blogs.sun.com/arungupta/date/20080514 Wednesday May 14, 2008

WAR-based Packaging and Deployment of Rails on GlassFish - Goldspike, RailServlet, Warbler, Rack, ...


WAR-based packaging and dispatching of Rails application on Java Application Servers is going through third iteration based what is used for packaging and dispatching:

  • Goldspike + RailsServlet: The first iteration was WAR-packaging of Rails app as defined by Goldspike plugin (nee Rails-integration) and using RailsServlet (part of Goldspike) for dispatching.
  • Warbler + RailsServlet: The second iteration (slightly short lived) overcame the shortcomings of Goldspike (packaging with sane defaults, fast, light-weight, and flexible configuration) by using Warbler for packaging. It decoupled packaging and dispatching by doing only packaging and allowing for pluggable dispatching mechanism. RailsServlet continues to be the default Servlet binding mechanism. This is the version currently supported by GlassFish v2 Update Center.
  • Warbler + Rack:  Nick released JRuby-Rack (JRuby version of Rack, also see Introducing Rack and Docs) last week. And so the third iteration is using Warbler packaging and Rack-based dispatching. JRuby-Rack provides a more seamless connection between the Servlet environment and Rack.

The JRuby-Rack wiki says "JRuby-Rack is a lightweight adapter for the Java servlet environment that allows any Rack-based application to run unmodified in a Java servlet container. JRuby-Rack supports Rails, Merb, as well as any Rack-compatible Ruby web framework.".

This means that, other than Rails, conceptually Merb applications (which also use Rack for deployment) can now also be deployed on GlassFish. This blog entry explains how to deploy a simple Rack-based Rails application.
  1. Install Rails and JRuby-Rack (as part of Warbler) as:

    ~/testbed/jruby-1.1.1 >bin/jruby -S gem install rails warbler --no-ri --no-rdoc
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Updating metadata for 289 gems from http://gems.rubyforge.org/
    ..............................................................................................................................
    ..............................................................................................................................
    .....................................
    complete
    Successfully installed activesupport-2.0.2
    Successfully installed activerecord-2.0.2
    Successfully installed actionpack-2.0.2
    Successfully installed actionmailer-2.0.2
    Successfully installed activeresource-2.0.2
    Successfully installed rails-2.0.2
    Successfully installed warbler-0.9.9
    7 gems installed
  2. Create a template Rails app as:

    ~/testbed/jruby-1.1.1/samples/rails >../../bin/jruby -S rails hello -d mysql
          create 
          create  app/controllers
          create  app/helpers
          create  app/models
          create  app/views/layouts
          create  config/environments
          . . .
          create  doc/README_FOR_APP
          create  log/server.log
          create  log/production.log
          create  log/development.log
          create  log/test.log
  3. Disable database access from the application by uncommenting line 21 (remove "#" at the beginning) from "config/environment.rb" as:

       config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
  4. Create a WAR file as:

    ~/testbed/jruby-1.1.1/samples/rails/hello >../../../bin/jruby -S warble
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    jar cf hello.war -C tmp/war .

  5. A new file "hello.war" is generated in the current directory.
  6. The generated WAR file can be easily deployed on GlassFish.
    1. Download and Install GlassFish v2 UR2 from here.
    2. Start GlassFish Application Server as:

      ~/testbed/glassfish/v2ur2/glassfish >bin/asadmin start-domain --verbose
      Starting Domain domain1, please wait.
      May 13, 2008 11:23:44 AM com.sun.enterprise.admin.servermgmt.launch.ASLauncher buildCommand
      INFO:
      /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
      . . .

      [#|2008-05-13T11:34:13.252-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;4848;|WEB0712: Starting Sun-Java-System/Application-Server HTTP/1.1 on 4848|#]

      [#|2008-05-13T11:34:13.691-0700|INFO|sun-appserver9.1|javax.enterprise.system.core.selfmanagement|_ThreadID=10;_ThreadName=main;|SMGT0007: Self Management Rules service is enabled|#]

      [#|2008-05-13T11:34:13.718-0700|INFO|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=10;_ThreadName=main;|Application server startup complete.|#]
    3. Deploy the WAR on GlassFish as:

      ~/testbed/jruby-1.1.1/samples/rails/hello >~/testbed/glassfish/v2ur2/glassfish/bin/asadmin deploy hello.war
      Command deploy executed successfully.

      The output in the GlassFish console looks like:

      [#|2008-05-13T11:34:23.330-0700|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;/private/tmp/s1astempdomain1server1547440193/hello.war;|ADM1006:Uploading the file to:[/private/tmp/s1astempdomain1server1547440193/hello.war]|#]

      [#|2008-05-13T11:34:26.019-0700|INFO|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=15;_ThreadName=Thread-30;|deployed with moduleid = hello|#]

      [#|2008-05-13T11:34:30.626-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-1;|PWC1412: WebModule[/hello] ServletContext.log():Info: using runtime pool timeout of 30 seconds|#]

      [#|2008-05-13T11:34:30.626-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-1;|PWC1412: WebModule[/hello] ServletContext.log():Warning: no initial runtimes specified.|#]

      [#|2008-05-13T11:34:30.627-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-1;|PWC1412: WebModule[/hello] ServletContext.log():Warning: no max runtimes specified.|#]
    4. The default Rails page is now visible at "http://localhost:8080/hello" as shown below:

  7. Add some functionality to the application to show Servlet and Rack integration
    1. Add a Controller and View as

      ~/testbed/jruby-1.1.1/samples/rails/hello >../../../bin/jruby script/generate controller home index
      JRuby limited openssl loaded. gem install jruby-openssl for full support.
      http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
            exists  app/controllers/
            exists  app/helpers/
            create  app/views/home
            exists  test/functional/
            create  app/controllers/home_controller.rb
            create  test/functional/home_controller_test.rb
            create  app/helpers/home_helper.rb
            create  app/views/home/index.html.erb
    2. Change the "index" helper method in "app/controllers/home_controller.rb" as:

      def index
              @greeting = "Hello from Rack!!"

              # access Servlet Context
              @server_info = $servlet_context.get_server_info
              # alternative way to get Servlet Context
              #@server_info2 = request.env['java.servlet_context'].get_server_info

              # access Servlet Request
              @method = request.env['java.servlet_request'].get_method
              @request_uri = request.env['java.servlet_request'].get_request_uri
              @protocol = request.env['java.servlet_request'].get_protocol
              @port = request.env['java.servlet_request'].get_server_port
      end
    3. Add the following fragment as the last line in "app/views/home/index.html.erb":

      <%= @greeting %><br><br>
      Hosted on "<%= @server_info %>" on port "<%= @port %>"<br>
      <%= @method %> <%= @request_uri %> <%= @protocol %>
  8. Re-create and deploy the WAR file
    1. Re-create the WAR file as explained in step 4.
    2. Re-deploy the WAR file as explained in step 5.3.
    3. Now "http://localhost:8080/hello/home/index" shows the output as:

The magic fragment in "tmp/war/WEB-INF/web.xml" is:

  <filter>
    <filter-name>RackFilter</filter-name>
    <filter-class>org.jruby.rack.RackFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>RackFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <listener>
    <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
  </listener>

And also "WEB-INF/lib/jruby-rack-0.9.jar" is bundled in the WAR.
Let us know if you try Rack-based deployment of Merb applications on GlassFish.

Technorati: rubyonrails jruby ruby rack merb glassfish

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080513 Tuesday May 13, 2008

"Miles to go ..." in Japanese


GlassFish Globalization team in Japan has started translating some of my blogs (on reader's request basis) in Japanese. The first installment is now live on GlassFish Wiki.

It's interesting to see that the first two translated entries are on Ruby-on-Rails. As of this morning, there are 71 blog entries on Ruby-on-Rails. Send them an email if you are interested in translation of other entries. Alternatively, you can edit the wiki and create a new entry in "Wishlist" section.

Let me know if you have suggestions on the type of GlassFish content that you'd like to see on this blog.

Feel free to create translation in a different language and drop a comment here.

Technorati: japanese blog translation rubyonrails

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080512 Monday May 12, 2008

JavaOne 2008 Wrapup


JavaOne 2008 is finally over ... 9th consecutive one for me and extremely busy as always!

And now let me talk about my formal speaking engagements (including the slides):
  • JavaU Bonus Evening Course on GlassFish Application Server - Shreedhar and I delivered a Bonus Evening Course on GlassFish in JavaU. We talked about GlassFish in depth - general overview, concepts, Metro Web services, dynamic languages support, high availability/clustering and lots of other details. The slides for the course are available here.

    Read more details in Shreedhar's Writeup.
  • GlassFish Unconference - Vivek and I led the "Scripting in GlassFish" session @ GlassFish Unconference and then I led the "Web services" session. It was very free-form forum, basically answering questions/clarifications from the participants and seeking feedback on our direction.

    It was great to know that people love Metro support in NetBeans and are some are using the IDE for that reason only.
  • Scripting in GlassFish (BOF 5111) - Vivek and I presented on "Scripting in GlassFish"and explained the support for different dynamic languages such as Ruby/Rails, Groovy/Grails, Python/Django on GlassFish. This preso showed bunch of demos including GlassFish v3 gem installation and deployment (screencast coming soon), GlassFish v3 Update Center, Rails Development/Deployment options, Groovy/Grails and Python/Django deployment. The slides are available here.

    You can find the latest information about support for different dynamic languages on glassfish-scripting.dev.java.net.
  • Lab 4530: Building Rich Web Applications with jMaki - Doris and I delivered Lab 4530: Building Rich Web Applications with jMaki. If you could not attend JavaOne, then you can follow the instructions at your own pace and download the entire lab.

    The complete material for all JavaOne 2008 Hands-on-Labs is available here. The material is pretty comprehensive and of high quality. I highly recommend refering to this material for sharpening your skills.
  • Tic Tac Tac @ General Session Keynote - I presented "Tic Tac Toe Demo" at General Session Keynote on Tuesday afternoon. This demo was a multi-player game developed in multiple scripting languages (Ruby, Groovy and Python) and their associated Web frameworks (Rails, Grails and Django) and all deployed on GlassFish v3 TP2. The main idea was to showcase multi-lingual support on GlassFish v3 and still able to use GlassFish features such as GlassFish Comet to push the events to browser. The entire source code for the demo will be released shortly and I'll announce the availability.

    You can watch the entire video here (starting at approx 1:10 into it). Hope you enjoy the War Games-esque look-and-feel. It was a keynote demo Hat-trick for me (jMaki/Phobos @ 2007, .NET Interoperability @ 2006. I'm happy to be labeled as "GlassFish Guy" :)
And then of course I met lots of others at the booth, in hallway/sessions/parties and elsewhere. I've taken few action items for generating new blogs/screencasts and they'll appear shortly on this blog.

I took lots of pictures through out the event and posted them regularly. They are all available here. A consolidated album is inlined:



Hope you had a great JavaOne and we were able to share our current roadmap and future plans with you successfully.

Technorati: conf javaone javaone2008 glassfish netbeans

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080510 Saturday May 10, 2008

Take 13 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 and the last lot of pictures from JavaOne 2008.

Music before Day 4 opening ...



All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080509 Friday May 09, 2008

Take 12 - Smash Mouth @ JavaOne 2008

Enjoy some videos of Smash Mouth @ JavaOne "After Dark" party.










All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 smashmouth sanfrancisco

del.icio.us | furl | simpy | slashdot | technorati | digg

Take 11 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and more pictures from JavaOne 2008.


All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080508 Thursday May 08, 2008

Take 10 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4, 5, 6, 7, 8, 9 and more pictures from JavaOne 2008.


All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

Take 9 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4, 5, 6, 7, 8 and more pictures from JavaOne 2008.


All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080507 Wednesday May 07, 2008

Take 8 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4, 5, 6, 7 and more pictures from JavaOne 2008.


All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

Take 7 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4, 5, 6 and more pictures from JavaOne 2008.


All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080506 Tuesday May 06, 2008

Take 6 - Pictures from JavaOne 2008

Enjoy the entertaining dance from JavaOne 2008 Day 1 kick off ...



Continuing from Take 1, 2, 3, 4, 5 and more pictures from JavaOne 2008.


All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

Take 5 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3, 4 and more pictures from JavaOne 2008.

GlassFish Tooling session ...



... Stairs to Hall B/C ...



... Hands-on-Lab preparing session ...


... GlassFish JavaU Evening Course (delivered by Shreedhar & myself) ...




And G2One party @ W ...




All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080505 Monday May 05, 2008

Take 4 - Pictures from JavaOne 2008

Continuing from Take 1, 2, 3 and more pictures from JavaOne 2008.

GlassFish Day Opening Session and GlassFish booth @ Community One ...









All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

Take 3 - Pictures from JavaOne 2008

Continuing from Take 1 and 2 and more pictures from JavaOne 2008.

GlassFish Party @ Thirsty Bear ...









All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg

http://blogs.sun.com/arungupta/date/20080504 Sunday May 04, 2008

Take 2 - Pictures from JavaOne 2008

Continuing from Take 1, more pictures from JavaOne 2008.

Agenda planning in GlassFish Unconference ...





Round 1 on GlassFish v3/OSGi and Clustering/High Availability ...


Round 2 on Community, Java EE and continues on v3/OSGi ...



And there were Round 3 & 4 where I participated actively so no pictures :)

All JavaOne 2008 pictures are available here.

Technorati: conf javaone javaone2008 photography

del.icio.us | furl | simpy | slashdot | technorati | digg
Main | Next page »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.

--> ajax ajaxworld conf</