Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.

http://blogs.sun.com/arungupta/date/20080724 Thursday July 24, 2008

Job Opportunity in GlassFish Web Container Team

What's common between

You are right - GlassFish is the answer!

If you are a fresh graduate, then apply for GlassFish Scripting team. However if you have
  • Experience in Developing Web container and related web-tier technologies such as JSP, Servlets, Java Server Faces and Java Standard Tag Libraries
  • Like to define the direction of Web container in Java EE platform and GlassFish Application Server
  • Worked in the Open Source & distributed teams
  • Like to play "follow the leader" where you are the leader :)
Then GlassFish team needs you. Apply now!

Technorati: glassfish webtier jsp servlets jstl javaserverfaces job

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

http://blogs.sun.com/arungupta/date/20080630 Monday June 30, 2008

Substruct on GlassFish v3 - Ruby-on-Rails E-Commerce Application


Substruct is an open-source E-Commerce project written using Ruby-on-Rails framework. It provides a simple e-commerce platform, content management system and customer response system - all in one.


I found out about this application from Sang "Passion" Shin's Lab 5542 (part of FREE 20-week course on Ruby-on-Rails starting on Jul 15, 2008). But instead of using standard WEBrick/Mongrel deployment, I describe the steps to deploy this application using GlassFish v3 Gem. The GlassFish Gem installation is described here.
  1. Download and install Substruct

    ~/samples/jruby >gunzip -c substruct_rel_1-0-a3.tar.gz  | tar xvf -
    substruct_rel_1-0-a3/
    substruct_rel_1-0-a3/app/
    substruct_rel_1-0-a3/app/controllers/
    substruct_rel_1-0-a3/app/controllers/application.rb
    . . .
    substruct_rel_1-0-a3/vendor/rails/railties/test/rails_info_test.rb
    substruct_rel_1-0-a3/vendor/rails/railties/test/secret_key_generation_test.rb
    substruct_rel_1-0-a3/vendor/rails/Rakefile
    substruct_rel_1-0-a3/vendor/rails/release.rb
  2. Install the required gems for Substruct

    ~/samples/jruby >~/testbed/jruby-1.1.2/bin/jruby -S gem install RedCloth fastercsv mime-types mini_magick ezcrypto jruby-openssl --no-ri --no-rdoc
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Bulk updating Gem source index for: http://gems.rubyforge.org/
    Successfully installed RedCloth-3.0.4
    Successfully installed fastercsv-1.2.3
    Successfully installed mime-types-1.15
    Successfully installed rubyforge-1.0.0
    Successfully installed hoe-1.5.3
    Successfully installed mini_magick-1.2.3
    Successfully installed ezcrypto-0.7
    Successfully installed jruby-openssl-0.2.3
    8 gems installed
  3. Create the database

    ~/samples/jruby/substruct_rel_1-0-a3 >~/testbed/jruby-1.1.2/bin/jruby -S rake db:create
    (in /Users/arungupta/samples/jruby/substruct_rel_1-0-a3)
    [SUBSTRUCT WARNING]
    Mail server settings have not been initialized.
    Check to make sure they've been set in the admin panel.
  4. And bootstrap it as

    ~/samples/jruby/substruct_rel_1-0-a3 >~/tesbted/jruby-1.1.2/bin/jruby -S rake substruct:db:bootstrap
    (in /Users/arungupta/samples/jruby/substruct_rel_1-0-a3)
    Checking requirements...
    Initializing database...
    [SUBSTRUCT WARNING]
    Mail server settings have not been initialized.
    Check to make sure they've been set in the admin panel.
    -- create_table("content_nodes", {:force=>true})
       -> 0.3020s
    -- add_index("content_nodes", ["name"], {:name=>"name"})
       -> 0.0140s
    -- add_index("content_nodes", ["type", "id"], {:name=>"type"})
    . . .
    -- initialize_schema_information()
       -> 0.0200s
    -- columns("schema_info")
       -> 0.0650s
    Clearing previous data...
    Removing all sessions...
    Loading default data...
    ...done.
    ================================================================================

    Thanks for trying Substruct 1.0.a3

    Now you can start the application with 'script/server'
    visit: http://localhost:3000/admin, and log in with admin / admin.

    For help, visit the following:
      Official Substruct Sites
        - http://substruct.subimage.com
        - http://code.google.com/p/substruct/
      Substruct Google Group - http://groups.google.com/group/substruct

    - Subimage LLC - http://www.subimage.com
  5. And finally run it on the GlassFish as:

    ~/samples/jruby >~/testbed/jruby-1.1.2/bin/jruby -S glassfish_rails substruct_rel_1-0-a3
    May 28, 2008 1:47:46 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    INFO: Launching GlassFish on HK2 platform
    May 28, 2008 1:47:46 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient
    INFO: Cannot find javadb client jar file, jdbc driver not available
    May 28, 2008 1:47:47 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3000
    May 28, 2008 1:47:47 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
    WARNING: pewebcontainer.all_ssl_protocols_disabled
    May 28, 2008 1:47:47 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
    WARNING: pewebcontainer.all_ssl_ciphers_disabled
    May 28, 2008 1:47:47 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3131
    May 28, 2008 1:47:47 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3838
    May 28, 2008 1:47:48 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
    INFO: Admin Console Adapter: context root: /admin
    May 28, 2008 1:47:48 PM com.sun.enterprise.rails.RailsDeployer registerAdapter
    INFO: Loading application substruct_rel_1-0-a3 at /
    May 28, 2008 1:47:48 PM 
    INFO: Starting Rails instances
    May 28, 2008 1:47:56 PM com.sun.grizzly.jruby.RubyObjectPool$1 run
    INFO: Rails instance instantiation took : 8800ms
    May 28, 2008 1:47:56 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 10403 ms

The welcome screenshot looks like



Now copy GlassFish logo image file to "public/images" directory of your application and add the following line to "app/views/layouts/main.rhtml" file (on line 36):

<a href="http://glassfish.org"><%= image_tag('/images/glassfish-logo.gif', :alt => 'GlassFish') %></a>

The modified view looks like as shown below:



The updated output looks like:



I tried only the basic deployment and that seem to work. If you try slightly more advanced usecases then the functionality provided by RedCloth, fastercsv, mime-types, mini_magick and ezcrypto gems can be exercised as well. If you are running Substruct, try it and let us know.

If your Rails application does not work on the gem, file bugs here with "jruby" as "subcomponent" (default version is "v3").

Also check out Redmine on GlassFish v3.

Technorati: rubyonrails glassfish netbeans substruct webtier

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

http://blogs.sun.com/arungupta/date/20080530 Friday May 30, 2008

GlassFish and jMaki @ RailsConf Today


I was originally planning to give my first talk at Rails Conf on "Rails powered by GlassFish and jMaki". But I cannot travel for personal reasons and instead Craig McClanahan, who is an excellent speaker, has graciously agreed to speak. Craig has been involved with Rails, GlassFish and jMaki for a long time so feel free to poke hime at the talk, in the exhibit hall and afterwards.

Thanks Craig for the wishes! I had a great time @ RailsConf 2007 (here and here) but life is about priorities :)

More information about support for Dynamic Languages and their Frameworks on GlassFish can be found on glassfish-scripting.dev.java.net.

Technorati: conf railsconf railsconf08 jruby ruby rubyonrails glassfish jmaki webtier

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

http://blogs.sun.com/arungupta/date/20080528 Wednesday May 28, 2008

JRuby 1.1.2 released - Getting Started with v3 Gem


JRuby 1.1.2 was released yesterday - download here!

The highlights are:

  • Startup time drastically reduced
  • YAML symbol parsing >100x faster
  • Performance, threading, and stack depth improvements for method calls
  • Fixed several nested backref problems
  • Fixed bad data race (JRUBY-2483)
  • Gazillions of bigdecimal issues fixed
  • 95 issues resolved since JRuby 1.1.1
Getting started is really simple, just follow the steps listed below.

Unzip JRuby 1.1.2 zip bundle ...

~/testbed/ >unzip ~/Downloads/jruby-bin-1.1.2.zip
Archive:  /Users/arungupta/Downloads/jruby-bin-1.1.2.zip
   creating: jruby-1.1.2/
   creating: jruby-1.1.2/bin/
  inflating: jruby-1.1.2/bin/_jrubycleanup.bat 
  inflating: jruby-1.1.2/bin/_jrubyvars.bat 
  . . .
  inflating: jruby-1.1.2/share/ri/1.8/system/Zlib/crc_table-c.yaml 
  inflating: jruby-1.1.2/share/ri/1.8/system/Zlib/zlib_version-c.yaml 
  inflating: jruby-1.1.2/share/ri/1.8/system/created.rid 
  inflating: jruby-1.1.2/share/ri/1.8/system/fatal/cdesc-fatal.yaml 
~/testbed >

... and then install Rails and GlassFish v3 gem ...

~/testbed/jruby-1.1.2 >bin/jruby -S gem install rails glassfish --no-ri --no-rdoc
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Bulk updating Gem source index for: http://gems.rubyforge.org/
Bulk updating Gem source index for: http://gems.rubyforge.org/
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 glassfish-0.2.0-universal-java
6 gems installed

... and verify ...

~/testbed/jruby-1.1.2 >bin/jruby -S gem list g

*** LOCAL GEMS ***

glassfish (0.2.0)

... and now host any of your Rails application on v3 Gem (such as Redmine) ...

~/testbed/redmine >../jruby-1.1.2/bin/jruby -S glassfish_rails redmine-0.7
May 28, 2008 12:07:19 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on HK2 platform
May 28, 2008 12:07:19 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient
INFO: Cannot find javadb client jar file, jdbc driver not available
May 28, 2008 12:07:20 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3000
May 28, 2008 12:07:20 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_protocols_disabled
May 28, 2008 12:07:20 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_ciphers_disabled
May 28, 2008 12:07:20 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3131
May 28, 2008 12:07:20 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3838
May 28, 2008 12:07:21 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
INFO: Admin Console Adapter: context root: /admin
May 28, 2008 12:07:21 PM com.sun.enterprise.rails.RailsDeployer registerAdapter
INFO: Loading application redmine-0.7 at /
May 28, 2008 12:07:21 PM 
INFO: Starting Rails instances
May 28, 2008 12:07:26 PM 
SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
May 28, 2008 12:07:32 PM com.sun.grizzly.jruby.RubyObjectPool$1 run
INFO: Rails instance instantiation took : 11481ms
May 28, 2008 12:07:32 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 12787 ms

Below is the screenshot from a previously deployed Redmine application, now on the GlassFish gem:



Simple isn't it ?

If your Rails application does not work on the gem, file bugs here with "jruby" as "subcomponent" (default version is "v3").

Alternatively, you can download GlassFish v3 TP2 and deploy your applications to leverage complete Java EE functionality.

You can also configure JRuby 1.1.2 as a Ruby platform in NetBeans 6.1 as described in TOTD #27.

Technorati: jruby ruby rubyonrails glassfish v3 gem redmine netbeans webtier

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

http://blogs.sun.com/arungupta/date/20080523 Friday May 23, 2008

Redmine on GlassFish - Ruby-on-Rails Project Management Application



Redmine
is a flexible project management web application written using Ruby on Rails framework. The feature list is pretty comprehensive from the usual suspects like multiple projects, role-based control, forums/wikis/SCM for each project to enterprise level features such as LDAP-authentication and multiple languages. It is cross-platform and cross-database and deploys very nicely on GlassFish v3.

GlassFish v3 modularity and extensibility allows Rails applications to be deployed without any modification (no WARing). This blog explains the steps on how to deploy Redmine on GlassFish and shows some screenshots later. More documentation is available in Redmine Guide.

  1. Check out the most stable release of Redmine by giving the command:

    ~/testbed/redmine >svn co http://redmine.rubyforge.org/svn/branches/0.7-stable redmine-0.7
  2. Configure the database
    1. Start your MySQL server 

      ~/testbed/redmine >sudo mysqld_safe --user root
      Starting mysqld daemon with databases from /usr/local/mysql/data
    2. Create the database as:

      ~/testbed/redmine/redmine-0.7 >../jruby-1.1.1/bin/jruby -S rake db:create
      (in /Users/arungupta/testbed/redmine/redmine-0.7)
    3. Migrate the database as:

      ~/testbed/redmine/redmine-0.7 >../jruby-1.1.1/bin/jruby -S rake db:migrate
      (in /Users/arungupta/testbed/redmine/redmine-0.7)
      == 1 Setup: migrating =========================================================
      -- create_table("attachments", {:force=>true})
         -> 0.2840s
      -- create_table("auth_sources", {:force=>true})
         -> 0.0540s
      -- create_table("custom_fields", {:force=>true})
         -> 0.0430s
      -- create_table("custom_fields_projects", {:id=>false, :force=>true})
         -> 0.0080s
      -- create_table("custom_fields_trackers", {:id=>false, :force=>true})
         -> 0.0500s

      . . .

      == 90 ChangeVersionsNameLimit: migrating ======================================
      -- change_column(:versions, :name, :string, {:limit=>nil})
         -> 0.0220s
      == 90 ChangeVersionsNameLimit: migrated (0.0220s) =============================

      == 91 ChangeChangesetsRevisionToString: migrating =============================
      -- change_column(:changesets, :revision, :string, {:null=>false})
         -> 0.0210s
      == 91 ChangeChangesetsRevisionToString: migrated (0.0230s) ====================

      == 92 ChangeChangesFromRevisionToString: migrating ============================
      -- change_column(:changes, :from_revision, :string)
         -> 0.0130s
      == 92 ChangeChangesFromRevisionToString: migrated (0.0150s) ===================
  3. Download, Install and Configure GlassFish v3
    1. Download GlassFish v3 from here.
    2. Unzip the downloaded bundle.
    3. Add the following fragment as the last line in "glassfishv3-tp2/glassfish/config/asenv.conf" file:

      JRUBY_HOME="/Users/arungupta/testbed/redmine/jruby-1.1.1"
  4. Deploy Redmine as:

    ~/testbed/redmine >./glassfishv3-tp2/glassfish/bin/asadmin deploy redmine-0.7
    Command deploy executed successfully.

    ... and the GlassFish console shows:

    May 21, 2008 4:58:30 PM com.sun.enterprise.rails.RailsDeployer registerAdapter
    INFO: Loading application redmine-0.7 at /redmine-0.7
    May 21, 2008 4:58:30 PM 
    INFO: Starting Rails instances
    May 21, 2008 4:58:37 PM 
    SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    May 21, 2008 4:58:42 PM com.sun.grizzly.jruby.RubyObjectPool$1 run
    INFO: Rails instance instantiation took : 11979ms
    May 21, 2008 4:58:42 PM com.sun.enterprise.v3.deployment.DeployCommand execute
    INFO: Deployment of redmine-0.7 done is 12091 ms
That's it, your application is ready to be used! Here are some screen snapshots from my trial run:


















Rails powered by the GlassFish Application Server provides all the good reasons on why you should consider using GlassFish instead of the traditional deployment models for Ruby-on-Rails applications.

This application is also covered in LAB 5539 as part of FREE 20-week Ruby-on-Rails course by Sang "with Passion" Shin.

Technorati: web2.0 rubyonrails jruby ruby glassfish redmine

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

http://blogs.sun.com/arungupta/date/20080522 Thursday May 22, 2008

Socialsite @ Enterprise 2.0 Conference - Add social networking to your community


Sun Microsytems is a sponsor of Enterprise 2.0 Conference (Jul 9-12, 2008, Boston).

The conference has regular tutorials, keynotes and general sessions, multiple tracks and pavilion (even a free pavilion pass). They also have Launch Pad that allow companies developing new social networking products to compete for the chance to present them in front of the largest audience in the Enterprise 2.0 community.

There are 8 companies in Round 2 and each one of them has submitted a video highlighting their offering. One of the semi-finalists is Project Socialsite - an offering from Sun Microsystems.

Project SocialSite makes it easy to add social networking features to your existing web applications or community sites (running on Java, PHP or Ruby) and turn it into an OpenSocial container. It comes with a comprehensive and highly scalable implementation of social graph, integrates seamlessly with existing identity and authentication mechanism, make it easy to plug into existing directory server or other user management systems.

The submitted video shows how easy it is add social networking features (such as Profile, Friends and Activity) to MediaWiki by adding simple tags. We hope you like the functionality shown and give us a higher rating to help us qualify for finals :)

Follow the conference blog, Facebook group or participate using conference wiki.

Technorati: conf enterprise2.0 socialsite web2.0

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

http://blogs.sun.com/arungupta/date/20080521 Wednesday May 21, 2008

Embeddable GlassFish in Action - Servlet in a Maven project

Kohsuke announced the embedability of GlassFish v3 - this is really cool! Now you can run GlassFish inside an existing JVM, without the need to start it externally. The API javadocs are available here. This blog explains how to host a Servlet using these APIs and write a simple Maven test to invoke the Servlet - all within the same VM.

The blog creates a Maven project using NetBeans but Maven CLI can be used as well.

In the NetBeans IDE, if Maven plugin is not already installed, then install it using "Tools", "Plugins","Available Plugins".

  1. Create a new Maven project
    1. Create a new project in NetBeans IDE and select "Maven" types as shown below



      Click on "Next >".
    2. Take the default "Archetype" as shown:



      Click on "Next >".
    3. Enter the "Project Name" and "Artifact Id" as shown below:



      and click on "Finish". The following output is shown in NetBeans Output window:



      This confirms the successful creation of the project.

      The command-line equivalent for all the above steps is:

      mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=org.glassfish.embedded.samples -DartifactId=webtier
  2. Update pom.xml with repositories & dependencies
    1. Expand "Project Files" and open "pom.xml". Add the following repositories (right after <url>...</url> tags)

      <repositories>
          <repository>
            <id>glassfish-repository</id>
            <name>Java.net Repository for Glassfish</name>
            <url>http://download.java.net/maven/glassfish</url>
          </repository>
          <repository>
            <id>download.java.net</id>
            <name>Java.net Maven Repository</name>
            <url>http://download.java.net/maven/2</url>
          </repository>
        </repositories>
    2. Add the following fragment after "<repositories>" to set the target JDK as 1.5:

      <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.0.2</version>
              <configuration>
                <source>1.5</source>
                <target>1.5</target>
             </configuration>
           </plugin>
         </plugins>
       </build>
    3. Add the following dependencies (inside "<dependencies>" and after "</dependency>")

      <dependency>
            <groupId>org.glassfish.distributions</groupId>
            <artifactId>web-all</artifactId>
            <version>10.0-build-20080430</version>
          </dependency>
          <dependency>
            <groupId>org.glassfish.embedded</groupId>
            <artifactId>gf-embedded-api</artifactId>
            <version>1.0-alpha-4</version>
          </dependency>
  3. Add Servlet class
    1. Right-click on "Source packages", select "New", "Java Class..." and enter the value as shown below



      and click on "Finish".
    2. Replace the template class with the following Servlet

      package org.glassfish.embedded.samples.webtier;

      import java.io.IOException;
      import java.io.PrintWriter;
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;

      /**
       * @author Arun Gupta
       */
      public class SimpleServlet extends HttpServlet {

          @Override
          protected void doGet(HttpServletRequest request,
                  HttpServletResponse response)
                  throws ServletException, IOException {
              PrintWriter out = response.getWriter();
              out.println("Wow, I'm embedded!");
          }
      }

      This is a simple Servlet class.
  4. Add deployment descriptor (this step could be made optional with possibly a default mapping)
    1. In the "Files" window, expand "src", "main", right-click and select "New", "Folder..." as shown below ...



      and give the folder name as "resources" as shown ...



      ... click on "Finish".
    2. Using the same mechanism, create a new folder "WEB-INF" in "resources". Right-click on "WEB-INF" and select "New", "XML Document..." as shown:

    3. Enter the name as "web" as shown


    4. Click on "Next >", take defaults and click on "Finish". Replace the content of generated "web.xml" with the following ...

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
          <servlet>
              <servlet-name>SimpleServlet</servlet-name>
              <servlet-class>org.glassfish.embedded.samples.webtier.SimpleServlet</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>SimpleServlet</servlet-name>
              <url-pattern>/SimpleServlet</url-pattern>
          </servlet-mapping>
      </web-app>

  5. Add a new test to invoke the Servlet
    1. In "Projects", expand "Test Packages" and open "org.glassfish.embedded.samples.webtier.AppTest" as shown:

    2. Add the following fragment at end of the class:

          private final String NAME = "AppTest";

          public void testServlet() throws Exception {
              int port = 9999;
              GlassFish glassfish = newGlassFish(port);
              URL url = new URL("http://localhost:" + port + "/" + NAME + "/SimpleServlet");
              BufferedReader br = new BufferedReader(
                      new InputStreamReader(
                      url.openConnection().getInputStream()));
              assertEquals("Wow, I'm embedded!", br.readLine());
              glassfish.stop();
          }

          private GlassFish newGlassFish(int port) throws Exception {
              GlassFish glassfish = new GlassFish(port);
              ScatteredWar war = new ScatteredWar(NAME,
                      new File("src/main/resources"),
                      new File("src/main/resources/WEB-INF/web.xml"),
                      Collections.singleton(new File("target/classes").toURI().toURL()));
              glassfish.deploy(war);
              System.out.println("Ready ...");
              return glassfish;
          }
    3. Right-click in the editor window and select "Fix Imports" as shown


    4. Take all the defaults as shown



      and click on "OK".
    5. The complete project structure looks like:

  6. Run the Test (mvn test)
    1. In Projects window, right-click the project and select "Test" as shown:

    2. The Output window shows the result as:



      Notice how GlassFish v3 started in 598 milliseconds (around 0.5 sec) and all the tests passed.
This is a work in progress and we would like to hear your feedback at users@glassfish and GlassFish Forum.

How are you using GlassFish embeddability ?

Technorati: glassfish v3 embedded servlet netbeans

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

http://blogs.sun.com/arungupta/date/20080520 Tuesday May 20, 2008

FREE 20-week Ruby-on-Rails Programming Course - with Passion!


Sang Shin and Brian Leonard are starting a new free online course of "Ruby, JRuby and Rails Application Development (with Passion!)". The course is taken online and will start from Jul 15, 2008.

The objective of this course are "This course will go through briefly the basics of Ruby (and JRuby) programming language first.  The rest of the course will be devoted to learning Rails functionality such as Active Record, Active Controller, and Active View.  Attendees will acquire sufficient knowledge in order to write reasonably sophisticated Rails application upon completion." Read more details here.

In this course, you'll learn various NetBeans and GlassFish tricks for Ruby-on-Rails development and deployment.

Read the Registration FAQ and send a blank email to ruby-on-rails-programming-with-passion-subscribe@googlegroups.com to register.

This course runs very much like a regular college course in which the students are expected to do weekly homework after studying the learning material and doing the hands-on
lab. By registering with the email address above, students can ask/answer questions. Some quick links ...
It is FREE and can be taken online, so what are you waiting for - register now!

Technorati: rubyonrails jruby ruby glassfish netbeans web2.0

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

http://blogs.sun.com/arungupta/date/20080519 Monday May 19, 2008

Benefit of using JRuby-on-Rails: Using Java 2D power within Rails


One of the main advantages of using JRuby-on-Rails instead of Ruby-on-Rails is to harness the power of Java libraries available in the Java platform. The Java 2D API is a set of classes for advanced 2D graphics and imaging, and provides extensive support for image compositing and alpha channel images, a set of classes to provide accurate color space definition and conversion, and a rich set of display-oriented imaging operators.

Jennifer published a new blog showing image-filtering effect (negative, grayscale, brigthen, sharpen). Read the complete entry.

A more comprehensive tutorial for JRuby-on-Rails on GlassFish v3 TP2 (also Jennifer's work) is available here.

Technorati: rubyonrails ruby jruby glassfish v3 java2d web2.0

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

http://blogs.sun.com/arungupta/date/20080517 Saturday May 17, 2008

Ask The "JRuby + NetBeans + GlassFish" Experts


NetBeans and GlassFish have changed the landscape of Ruby, JRuby and Rails development and deployment. Code completion, debugging, similar development and deployment environment and many other features (NetBeans, GlassFish) together make it a compelling offering.

Tor Norbye, Brian Leonard and Charles Nutter are fielding questions on Ruby/JRuby/Rails support in the NetBeans IDE and GlassFish in a week-long Ask The Expert session (May 19-23). A complete archive of the Q&A will be available later. You can submit your question here.

If "Ask The Expert" window is missed, the questions can always be asked on user@jruby.codehaus.org, users@glassfish.dev.java.net and users@ruby.netbeans.org.

Technorati: ruby jruby rubyonrails netbeans glassfish web2.0

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

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 web2.0

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

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

GlassFish v3 Gem 0.2.0 released


A newer version of GlassFish v3 Gem for Ruby on Rails is now available.

What's new ?

  • Codebase aligned with GlassFish v3 Technology Preview 2
  • Previous version (0.1.2) had some packaging issues which increased the size but now it's back to sweet 2.8 Mb.
Check if previously installed by using the following command:

~/testbed/jruby-1.1.1 >bin/jruby -S gem list glassfish

*** LOCAL GEMS ***

glassfish (0.1.2)

If already installed (as indicated by the list of gems) then uinstall it using the following command:

~/testbed/jruby-1.1.1 >bin/jruby -S gem uninstall glassfish
Successfully uninstalled glassfish-0.1.2-universal-java
Remove executables:
        glassfish_rails, asadmin, asadmin.bat

in addition to the gem? [Yn]  y
Removing glassfish_rails
Removing asadmin
Removing asadmin.bat

And then install it again as:

~/testbed/jruby-1.1.1 >bin/jruby -S gem install glassfish
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Successfully installed glassfish-0.2.0-universal-java
1 gem installed

Updating the gem is giving unpredictable results (mostly not updating) and will be investigated later.

Rails powered by the GlassFish Application Server explains why GlassFish is a better deployment option for Rails applications.

All the latest information about the gem can be found at GlassFish JRuby wiki or JRuby wiki.

Please use the gem and send us feedback on GlassFish forums, dev@glassfish or gem mailing list.

Technorati: rubyonrails jruby ruby glassfish v3 gem

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

http://blogs.sun.com/arungupta/date/20080503 Saturday May 03, 2008

JRuby 1.1.1, Rails 2.0.2, Warbler now in GlassFish v2 Update Center


Vivek updated JRuby module in GlassFish v2 UR2 Update Center. It now contains JRuby 1.1.1 + Rails 2.0.2 and Warbler (instead of Goldspike) for packaging the app.

Read all details on how to download, install and getting started here. The image below shows a snapshot of Update Center with the latest module selected:


After following all the steps (had to manually set executable perms on jruby-1.1.1/bin/jruby), your application is now hosted at "http://localhost:8080/HelloWorldRailsApp/say/hello" and shows the following output:



The generated "HelloWorldRailsApp.war" is approx 8.5 Mb and could quickly grow depending upon the gems installed and other factors. As an alternative, you can consider shared deployment as explained in each sample's GLASSFISH_README.txt.

Send us feedback at Forums or webtier@glassfish.

Technorati: rubyonrails jruby ruby glassfish updatecenter

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

http://blogs.sun.com/arungupta/date/20080421 Monday April 21, 2008

JRuby and GlassFish v2 - Another successful deployment @ WorldxChange Communication NZ


From proof-of-concept to production in 8 weeks, WorldxChange Communication NZ's online billing system is another succes story of JRuby and GlassFish v2. The portal is designed solely using NetBeans 6.1 IDE.

Here are some of the quotes from the completed questionnaire:

From my perspective, the main advantage was that I could deploy my JRuby project war file directly to Glassfish, allowing me to develop and test our online ViewBill portal using a production grade, scalable web server.

From a geek perspective, we love that Glassfish combined with JRuby and allowed us to integrate many different disparate systems to create a seamless interface for our customers to use.

started using the Glassfish v3 gem for final testing of new code releases and to check functionality prior to production deployment.

I do not believe that I could have developed this project any faster using different toolsets or technologies and have been massively impressed with the combination of Glassfish and JRuby.

Read more details here.

Rails powered by the GlassFish Application Server explains why to use GlassFish for powering your Rails applications.

You can find all all about JRuby and GlassFish efforts on the GlassFish wiki or JRuby wiki.

Technorati: glassfish netbeans rubyonrails jruby ruby stories

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

http://blogs.sun.com/arungupta/date/20080129 Tuesday January 29, 2008

JRuby-on-Rails deployed on GlassFish - Success Story

There are several reasons you may deploy JRuby-on-Rails application on GlassFish:

  • Java EE is a long tested deployment platform and GlassFish is Java EE 5 compliant.
  • GlassFish "green" deployment model - just create a WAR and dump it in autodeploy directory. Typical Rails deployment requires to spawn multiple Mongrels, front-ended by Apache and then manage them through Capistrano.
  • Java EE and Ruby-on-Rails applications can be easily integrated in one container. This allows to host JRuby-on-Rails applications in organization who have already made investment in Java EE.
  • GlassFish comes with out-of-the-box clustering and high-availability support. Rails applications can certainly benefit from them.
  • GlassFish offers database connection pooling allowing you to reuse your database connections.
  • Last, but not the least, JRuby-on-Rails can leverage the extensive set of Java libraries.
I'm working on an article that will explain each of these in detail. In the meanwhile here is a live success story.

mediacast.sun.com (provides a public place for Sun employees to store large media files) released their version 2.0 - completely rewritten using JRuby-on-Rails and deployed on GlassFish. Igor has good details is his blog. Here are some excerpts:

Development environment: NetBeans 6, Mercurial plugin, WEBrick, GlassFish v2 UR1, MySQL
Deployment environment: 2 Load-balanced T2000, Solaris 10, Sun Java System Application Server 9.1 U1, JDK 6, MySQL

He has explained the pain points and areas of improvements very clearly. We are aware of the performance problems and already working on them!

Let us know if you have had success with deploying JRuby-on-Rails on GlassFish. Read all GlassFish success stories.

UPDATE (Feb 8): Mediacast deployment diagram is now available here.

Technorati: glassfish netbeans jruby rubyonrails mediacast stories

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

Valid HTML! Valid CSS!

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