Miles to go …

June 30, 2008

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

Filed under: web2.0 — arungupta @ 5:00 am


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):

able style="text-align: left; width: 100%;" cellpadding="2" cellspacing="2">

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

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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 27, 2008

GlassFish on Eclipse Ganymede

Filed under: General — arungupta @ 4:00 am
Eclipse Ganymede is the annual release of Eclipse projects; this year including 23 projects. Screencast #WS6 showed how GlassFish v2 can be easily registered and started within an earlier version of Eclipse (3.3 specifically).

Eclipse is now 3.4 (as part of Ganymede) and GlassFish v3 is blazing the community with it’s modular, embeddable and extensible architecture.

This blog shows how GlassFish v3 can be easily registered and started in Ganymede. Let’s get started!

Download Ganymede and GlassFish v3 TP2 or build the latest workspace. Check Eclipse version by selecting “Eclipse”, “About Eclipse platform” menu item. The window shows:

Now follows the screenshots as described in screencast #ws6 but this time for Ganymede instead of Eclipse Europa:

Create a new server …

… and the window shows the list of default servers …

… click on “Download additional server adapters” to see GlassFish in the list …

… select “GlassFish Java EE 5 Server” and click on “Next >” …

… accept the license and take all other defaults. The IDE needs to be restarted and then again you add a new server …

… and this time choose “GlassFish V3 SNAPSHOT” …

and specify the location of downloaded/built GlassFish v3 server. Now create a new project …

… give it a name …

… and ensure the “Target Runtime” is “GlassFish V3 SNAPSHOT”. And the default project structure is shown below …

… and now add a JSP …

… and give it a name …

… and then select a template …

… and add some content to it …

… and then deploy on GlassFish by selecting “Run As”, “Run on Server” …

… and selecting “GlassFish V3 SNAPSHOT” as the server …

and click on “Finish” to see the result …

and that’s it!

As a next step, you can try installing Metro on TP2 and then deploy your Web service using Eclipse. If you face any problems then send email to or post a question to GlassFish Forum.

And if you are interested in a tighter integration of GlassFish v3 with an IDE  - NetBeans provides that solution as shown in screencast #24.

Technorati: eclipse ganymede glassfish v3

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 26, 2008

TOTD #36: Deploy OSGi bundles in GlassFish using maven-bundle-plugin

Filed under: General — arungupta @ 5:00 am

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 Servlet. This blog demonstrates how a simple OSGi bundle can be easily created using Maven Bundle Plugin and deployed on v3 trunk.

  1. Generate a simple Maven project using the command as shown below:

    ~/samples/v3 >mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=org.glassfish.samples.osgi.helloworld -DartifactId=helloworld
    [INFO] Scanning for projects…
    [INFO] Searching repository for plugin with prefix: ‘archetype’.
    [INFO] Ignoring available plugin update: 2.0-alpha-3 as it requires Maven version 2.0.7
    [INFO] Ignoring available plugin update: 2.0-alpha-2 as it requires Maven version 2.0.7
    [INFO] Ignoring available plugin update: 2.0-alpha-1 as it requires Maven version 2.0.7
    [INFO] —————————————————————————-
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [archetype:create] (aggregator-style)
    [INFO] —————————————————————————-
    [INFO] Setting property: classpath.resource.loader.class => ‘org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader’.
    [INFO] Setting property: velocimacro.messages.on => ‘false’.
    [INFO] Setting property: resource.loader => ‘classpath’.
    [INFO] Setting property: resource.manager.logwhenfound => ‘false’.
    [INFO] **************************************************************
    [INFO] Starting Jakarta Velocity v1.4
    [INFO] RuntimeInstance initializing.
    [INFO] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
    [INFO] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
    [INFO] Resource Loader Instantiated: org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
    [INFO] ClasspathResourceLoader : initialization starting.
    [INFO] ClasspathResourceLoader : initialization complete.
    [INFO] ResourceCache : initialized. (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
    [INFO] Default ResourceManager initialization complete.
    [INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Literal
    [INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Macro
    [INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Parse
    [INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Include
    [INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
    [INFO] Created: 20 parsers.
    [INFO] Velocimacro : initialization starting.
    [INFO] Velocimacro : adding VMs from VM library template : VM_global_library.vm
    [ERROR] ResourceManager : unable to find resource ‘VM_global_library.vm’ in any resource loader.
    [INFO] Velocimacro : error using  VM library template VM_global_library.vm : org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource ‘VM_global_library.vm’
    [INFO] Velocimacro :  VM library template macro registration complete.
    [INFO] Velocimacro : allowInline = true : VMs can be defined inline in templates
    [INFO] Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
    [INFO] Velocimacro : allowInlineLocal = false : VMs defined inline will be  global in scope if allowed.
    [INFO] Velocimacro : initialization complete.
    [INFO] Velocity successfully started.
    [INFO] [archetype:create]
    [INFO] Defaulting package to group ID: org.glassfish.samples.osgi.helloworld
    [INFO] ——–
    ——————————————————————–

    [INFO] Using following parameters for creating Archetype: maven-archetype-quickstart:RELEASE
    [INFO] —————————————————————————-
    [INFO] Parameter: groupId, Value: org.glassfish.samples.osgi.helloworld
    [INFO] Parameter: packageName, Value: org.glassfish.samples.osgi.helloworld
    [INFO] Parameter: basedir, Value: /Users/arungupta/samples/v3
    [INFO] Parameter: package, Value: org.glassfish.samples.osgi.helloworld
    [INFO] Parameter: version, Value: 1.0-SNAPSHOT
    [INFO] Parameter: artifactId, Value: helloworld
    [INFO] ********************* End of debug info from resources from generated POM ***********************
    [INFO] Archetype created in dir: /Users/arungupta/samples/v3/helloworld
    [INFO] ————————————————————————
    [INFO] BUILD SUCCESSFUL
    [INFO] ————————————————————————
    [INFO] Total time: 1 second
    [INFO] Finished at: Wed Jun 25 10:07:27 PDT 2008
    [INFO] Final Memory: 5M/10M
    [INFO] ————————————————————————
  2. Change the generated App class in “src/main/java/org/glassfish/samples/osgi/helloworld” folder so that it looks like:
    package org.glassfish.samples.osgi.helloworld;

    import org.osgi.framework.BundleActivator;
    import org.osgi.framework.BundleContext;

    /**
     * Hello world!
     *
     */
    public class App implements BundleActivator {
        public void start(BundleContext context) throws Exception {
            System.out.println(“Hey!”);
        }
        public void stop(BundleContext context) throws Exception {
            System.out.println(“Bye!”);
        }
    }

    This is a trivial Activator class but sitll shows the key methods. The changes are highlighted in bold.

  3. Update “pom.xml” with the following changes:
    1. Change the <packaging> to “bundle” from the default value of “jar”.
    2. Add the <dependency> on “org.osgi.core”.
    3. Add the <plugin> maven-bundle-plugin and provide <instructions> to generate the appropriate MANIFEST.MF.

    The updated “pom.xml” with changes highlighted in bold are shown below:

    <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
      xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd”>
      <modelVersion>4.0.0</modelVersion>
      <groupId>org.glassfish.samples.osgi.helloworld</groupId>
      <artifactId>helloworld</artifactId>
      <packaging>bundle</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>helloworld</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.felix</groupId>
          <artifactId>org.osgi.core</artifactId>
          <version>1.0.0</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
              <instructions>
                <Export-Package>${pom.groupId}</Export-Package>
                <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                <Bundle-Activator>${pom.groupId}.App</Bundle-Activator>
              </instructions>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
  4. Generate the OSGi bundle as shown below:
    ~/samples/v3/helloworld >mvn install
    [INFO] Scanning for projects…
    [INFO] —————————————————————————-
    [INFO] Building helloworld
    [INFO]    task-segment: [install]
    [INFO] —————————————————————————-
    [INFO] [resources:resources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:compile]
    [INFO] Compiling 1 source file to /Users/arungupta/samples/v3/helloworld/target/classes
    [INFO] [resources:testResources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:testCompile]
    [INFO] Compiling 1 source file to /Users/arungupta/samples/v3/helloworld/target/test-classes
    [INFO] [surefire:test]
    [INFO] Surefire report directory: /Users/arungupta/samples/v3/helloworld/target/surefire-reports

    ——————————————————-
     T E S T S
    ——————————————————-
    Running org.glassfish.samples.osgi.helloworld.AppTest
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.022 sec

    Results :

    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

    [INFO] [bundle:bundle]
    [INFO] [install:install]
    [INFO] Installing /Users/arungupta/samples/v3/helloworld/target/helloworld-1.0-SNAPSHOT.jar to /Users/arungupta/.m2/repository/org/glassfish/samples/osgi/helloworld/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.jar
    [INFO] [bundle:install]
    [INFO] Parsing file:/Users/arungupta/.m2/repository/repository.xml
    [INFO] Installing org/glassfish/samples/osgi/helloworld/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.jar
    [INFO] Writing OBR metadata
    [INFO] ————————————————————————
    [INFO] BUILD SUCCESSFUL
    [INFO] ————————————————————————
    [INFO] Total time: 4 seconds
    [INFO] Finished at: Wed Jun 25 10:20:27 PDT 2008
    [INFO] Final Memory: 22M/54M
    [INFO] ————————————————————————

    The generated “target/helloworld-1.0-SNAPSHOT.jar” has the following contents:

    META-INF/MANIFEST.MF
    META-INF/
    META-INF/maven/
    META-INF/maven/org.glassfish.samples.osgi.helloworld/
    META-INF/maven/org.glassfish.samples.osgi.helloworld/helloworld/
    META-INF/maven/org.glassfish.samples.osgi.helloworld/helloworld/pom.properties
    META-INF/maven/org.glassfish.samples.osgi.helloworld/helloworld/pom.xml
    org/
    org/glassfish/
    org/glassfish/samples/
    org/glassfish/samples/osgi/
    org/glassfish/samples/osgi/helloworld/
    org/glassfish/samples/osgi/helloworld/App.class

    And the generated “MANIFEST.MF” looks like:


    Manifest-Version: 1.0
    Export-Package: org.glassfish.samples.osgi.helloworld;uses:=”org.osgi.
     framework”
    Built-By: arungupta
    Tool: Bnd-0.0.255
    Bundle-Name: helloworld
    Created-By: Apache Maven Bundle Plugin
    Bundle-Version: 1.0.0.SNAPSHOT
    Build-Jdk: 1.6.0_05
    Bnd-LastModified: 1214414426851
    Bundle-ManifestVersion: 2
    Bundle-Activator: org.glassfish.samples.osgi.helloworld.App
    Import-Package: org.glassfish.samples.osgi.helloworld,org.osgi.framewo
     rk;version=”1.3″
    Bundle-SymbolicName: helloworld

Now let’s install this newly created bundle using Felix shell in GlassFish v3. Check out and build GlassFish v3 workspace as explained in TOTD #33. Unzip “~/workspaces/glassfish/v3/distributions/web/target/web.zip” and enable Felix TUI as explained in TOTD #34.

  1. Start GlassFish v3 as:

    ~/testbed/glassfish/v3/snapshot/glassfish >java -jar modules/glassfish-10.0-SNAPSHOT.jar
    Jun 25, 2008 4:09:19 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    INFO: Launching GlassFish on Apache Felix OSGi platform
    Jun 25, 2008 4:09:19 PM com.sun.enterprise.glassfish.bootstrap.ASMainOSGi getSharedRepos
    INFO: /Users/arungupta/testbed/glassfish/v3/snapshot/glassfish/domains/domain1/lib does not exist

    Welcome to Feli
    x.

    =================

    Jun 25, 2008 4:09:20 PM HK2Main start
    INFO: contextRootDir = /Users/arungupta/testbed/glassfish/v3/snapshot/glassfish/modules
    Jun 25, 2008 4:09:20 PM OSGiFactoryImpl initialize
    INFO: Singleton already initialized as com.sun.enterprise.module.impl.HK2Factory@3d44d0c6
    Jun 25, 2008 4:09:20 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.common.glassfish-mbeanserver [19]
    Jun 25, 2008 4:09:20 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.core.kernel [51]
    Jun 25, 2008 4:09:21 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.common.glassfish-naming [8]
    Jun 25, 2008 4:09:21 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.admin.config-api [43]
    Jun 25, 2008 4:09:21 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.common.internal-api [33]
    Jun 25, 2008 4:09:21 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.deployment.deployment-common [10]
    Jun 25, 2008 4:09:21 PM 
    INFO: JMXMP connector server URL = service:jmx:jmxmp://localhost:8888
    Jun 25, 2008 4:09:21 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 8080
    Jun 25, 2008 4:09:21 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 8181
    Jun 25, 2008 4:09:21 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 4848
    Jun 25, 2008 4:09:21 PM OSGiModuleImpl loadClass
    INFO: Started bundle org.glassfish.common.container-common [21]
    Jun 25, 2008 4:09:22 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
    INFO: Admin Console Adapter: context root: /admin
    Jun 25, 2008 4:09:22 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 1789 ms
    Jun 25, 2008 4:09:22 PM 
    INFO: ->
    Jun 25, 2008 4:09:22 PM com.sun.enterprise.glassfish.bootstrap.ASMainFelix launchOSGiFW
    INFO: Framework successfully started
  2. Install the Hello World bundle as:
    install file:///Users/arungupta/samples/v3/helloworld/target/helloworld-1.0-SNAPSHOT.jar
    Jun 25, 2008 4:10:19 PM 
    INFO: Bundle ID: 75
    Jun 25, 2008 4:10:19 PM 
    INFO: ->

    The command output shows “75″ as the process id. This id is used to start/stop/uninstall the bundle later.

  3. Check the bundle status
    ps     
    Jun 25, 2008 4:10:27 PM 
    INFO: START LEVEL 1
    Jun 25, 2008 4:10:27 PM 
    INFO:    ID   State         Level  Name
    Jun 25, 2008 4:10:27 PM 
    INFO: [   0] [Active     ] [    0] System Bundle (1.0.4)
    Jun 25, 2008 4:10:27 PM 
    INFO: [   1] [Active     ] [    1] org.jvnet.tiger-types repackaged as module (0.3.2)
    Jun 25, 2008 4:10:27 PM 

    . . .

    INFO: [  71] [Installed 
    ] [    1] Web module command line interface (10.0.0.SNAPSHOT)

    Jun 25, 2008 4:10:27 PM 
    INFO: [  72] [Installed  ] [    1] Admin GUI Web Container Plugin (10.0.0.SNAPSHOT)
    Jun 25, 2008 4:10:27 PM 
    INFO: [  75] [Installed  ] [    1] helloworld (1.0.0.SNAPSHOT)
    Jun 25, 2008 4:10:27 PM 
    INFO: ->

    The last log output shows the newly added process.

  4. Start the bundle as:
    start 75
    Jun 25, 2008 4:10:32 PM 
    INFO: Hey!
    Jun 25, 2008 4:10:32 PM 
    INFO: ->

    This fragment shows “Hey!” output printed from the start method of Activator.

  5. Stop the bundle as:
    stop 75
    Jun 25, 2008 4:10:35 PM 
    INFO: Bye!
    Jun 25, 2008 4:10:35 PM 
    INFO: ->

    This fragment shows “Bye!” output printed from the stop method of Activator.

  6. And finally uninstall the bundle as:
    uninstall 75
    Jun 25, 2008 4:10:42 PM 
    INFO: ->

So following this blog you can deploy any of your OSGi bundles in GlassFish v3.

Technorati: glassfish v3 osgi maven mavenbundleplugin

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 25, 2008

Rails GlassFish Gem 0.3.1 now available

Filed under: web2.0 — arungupta @ 5:00 am

Vivek released 0.3.0 version of GlassFish Gem for Rails (a total of 11 issues fixed and resolved – RubyForge & GlassFish Issue Tracker) earlier. But that caused a regression on #4228. And so matching the agility expected by Rails developers, he quickly released 0.3.1. And a wee bit smaller too – 2.68MB for 0.3.1 instead of 2.69MB for 0.3.0.

If you have an existing version of the gem, then you just need to update it:

~/testbed/jruby-1.1 >bin/jruby -S gem update glassfish -r
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Updating installed gems…
Bulk updating Gem source index for: http://gems.rubyforge.org
Attempting remote update of glassfish
Successfully installed glassfish-0.3.1-universal-java
1 gem installed
Gems updated: glassfish

If the gem has never been installed, then you install it as:

~/testbed/jruby-1.1.2 >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.3.1-universal-java
1 gem installed

And make sure next time you have to update the gem instead of installing from scratch ;) For that, just install the gem this time and let us know your feedback on GlassFish Webtier Forum or Webtier Alias. If any of your Rails application do not work then please file bugs at GlassFish Issue Tracker (“V3″ as “Found in Version:” and “jruby” as “Subcomponent:”).

The gem installation may require to set “JAVA_MEM=-Xmx800m” because of the growing memory requirements. Otherwise you may get “Exception in thread “main” java.lang.OutOfMemoryError: Java heap space“.

Try a simple scaffold application to see the output as shown below:

The startup output in the gem console (output from GlassFish) is:

~/testbed/jruby-1.1.2/samples/rails >../../bin/jruby -S glassfish_rails runner
Jun 24, 2008 11:04:51 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on HK2 platform
Jun 24, 2008 11:04:51 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient
INFO: Cannot find javadb client jar file, jdbc driver not available
Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3000
Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_protocols_disabled
Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_ciphers_disabled
Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3131
Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3838
Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
INFO: Admin Console Adapter: context root: /admin
Jun 24, 2008 11:04:52 PM com.sun.grizzly.jruby.RailsAdapter startRubyRuntimePool
INFO: Starting Rails instances
Jun 24, 2008 11:04:58 PM 
SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Jun 24, 2008 11:04:59 PM com.sun.grizzly.jruby.RubyObjectPool$1 run
INFO: JRuby and Rails instance instantiation took : 6600ms
Jun 24, 2008 11:04:59 PM org.glassfish.scripting.rails.RailsDeployer load
INFO: Loading application runner at /
Jun 24, 2008 11:04:59 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 7945 ms

and then the console is updated as more entries are added (output from Rails):

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:

Processing DistancesController#index (for 0:0:0:0:0:0:0:1%0 at 2008-06-24 23:05:25) [GET]

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Session ID: BAh7ByIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo
SGFzaHsABjoKQHVzZWR7ADoMY3NyZl9pZCIlNTdhMGYxNjkxOTk5ZjI1ZjI4
OGZjODZjZjcxN2QyNzQ=–cbf4578767e5887d4b62bd249e7624dcb7d1cf90

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Parameters: {“cont
roller”=>”distances”, “action”=>”index”}


Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO: WARNING: You’re using the Ruby-based MySQL library that ships with Rails. This library is not suited for production. Please install the C-based MySQL library instead (gem install mysql).

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   SQL (0.001000)   SET NAMES ‘utf8′

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   SQL (0.001000)   SET SQL_AUTO_IS_NULL=0

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Load (0.003000)   SELECT * FROM `distances`

Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO: Rendering template within layouts/distances

. . .

Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Parameters: {“authenticity_token”=>”519436f2248515d901051acafe0726dfd88746f0″, “distance”=>{“miles”=>”4″, “run_at(1i)”=>”2008″, “run_at(2i)”=>”6″, “run_at(3i)”=>”24″, “run_at(4i)”=>”07″, “run_at(5i)”=>”00″}, “commit”=>”Create”, “controller”=>”distances”, “action”=>”create”}

Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Columns (0.009000)   SHOW FIELDS FROM `distances`

Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   SQL (0.000000)   BEGIN

Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Create (0.000000)   INSERT INTO `distances` (`miles`, `run_at`, `created_at`, `updated_at`) VALUES(4.0, ’2008-06-24 14:00:00′, ’2008-06-25 06:05:48′, ’2008-06-25 06:05:48′)

Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   SQL (0.002000)   COMMIT

. . .

Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Parameters: {“authenticity_token”=>”519436f2248515d901051acafe0726dfd88746f0″, “distance”=>{“miles”=>”3.5″, “run_at(1i)”=>”2008″, “run_at(2i)”=>”6″, “run_at(3i)”=>”23″, “run_at(4i)”=>”06″, “run_at(5i)”=>”55″}, “commit”=>”Create”, “controller”=>”distances”, “action”=>”create”}

Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Columns (0.015000)   SHOW FIELDS FROM `distances`

Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   SQL (0.000000)   BEGIN

Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Create (0.000000)   INSERT INTO `distances` (`miles`, `run_at`, `created_at`, `updated_at`) VALUES(3.5, ’2008-06-23 13:55:00′, ’2008-06-25 06:06:09′, ’2008-06-25 06:06:09′)

Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   SQL (0.001000)   COMMIT

Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO: Redirected to http://localhost:3000/distances/5

. . .

Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Parameters: {“controller”=>”distances”, “action”=>”index”}

Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Load (0.003000)   SELECT * FROM `distances`

Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO: Rendering template within layouts/distances

Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO: Rendering distances/index

Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO:   Distance Columns (0.008000)   SHOW FIELDS FROM `distances`

Jun 24, 2008 11:06:11 PM com.sun.grizzly.jruby.RailsAdapter$Logger log
INFO: Completed in 0.05900 (16 reqs/sec) | Rendering: 0.03200 (54%) | DB: 0.01100 (18%) | 200 OK [http://localhost/distances]

Redmine seems to have issues with Rails 2.1. I’ll play with some other applications later. But have you tried deploying your Rails application on GlassFish gem ? As mentioned above, let us know your feedback on GlassFish Webtier Forum or Webtier Alias and file bugs on GlassFish Issue Tracker.

Details about previous versions are available at 0.2.0, 0.1.2, 0.1.1, 0.1.0.

Technorati: glassfish v3 rubyonrails jruby ruby gem

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 24, 2008

JRuby-on-Rails and MySQL on GlassFish on OpenSolaris in Virtual Box VM

Filed under: web2.0 — arungupta @ 6:00 am

My primary development machine is Mac OS Leopard on Intel Core 2 Duo (read osxtips). But the beauty of virtualization is that I can run multiple Operating Systems on a single powerful machine. And what better virtualization product than Virtual Box. And  Open Solaris has crossed leaps and boundaries making installation and getting started extremely simple :)

So here is an application stack that I tried:


Rails 2.1 + My SQL 5.0.51a

JRuby 1.1.2

GlassFish v3 TP2

OpenSolaris 2008.05

Virtual Box 1.6.2


Mac OSX Leopard

Intel 2.4 G Hz Core 2 Duo

You can easily deploy your Rails applications using MySQL database on GlassFish installed on OpenSolaris in a Virtual Box VM on Mac OS Leopard running on an Intel 2 Duo processor machine. Overall a happy experience :)

The complete instructions to install OpenSolaris using Virtual Box are very useful.

Here are basic steps …

Create a new VM (settings given in the instructions):

Once all the options are chosen, the generated VM settings are shown as below:

Booting the Virtual Machine from the Live CD shows the following GRUB:

Pick the default options (GRUB, Keyboard & Language) and then the following default screen is shown:

Read and Close the license screen. And then click on the “Install Open Solaris” icon to continue the installation process. This step is important otherwise you’ll keep booting from LiveCD every time (I messed up on this few times ;) .

After choosing the Region, Location & Timezone and taking other defaults, the summarized installation options are shown:

And finally the installation is complete:

After the installation is complete, shutdown the VM by either selecting “System, Shut Down…” or click on the X on the VM window and selecting “Power off the machine”. Change the boot sequence order to bring “Hard Disk” at the top by clicking on “Settings”, “Advanced” tab and changing the order as shown below.

And finally, you can easily deploy a Rails 2.1 application on this newly configured machine as explained in Rails 2.1 on GlassFish.  TOTD #35 explains how Rails Database connection need to be configured on Solaris.
The final output of the application looks like:

Here are some pointers for you to get started:

  • Virtual Box 1.6.2
  • OpenSolaris 2008.05
  • GlassFish v3 TP2
  • JRuby 1.1.2
  • Rails powered by the GlassFish Application Server

Did you know the 3 keywords for GlassFish v3 – Modularity (OSGi compliant), Extensiblity (non-Java apps) & Emebeddability (runs in-VM) ? Read more on GlassFish v3 main page.

Stay in touch with us by posting your questions/comments/concerns to GlassFish Web Tier Forum or .

Technorati: rubyonrails jruby ruby opensolaris virtualbox mac glassfish v3

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 23, 2008

New “Community: GlassFish” category for java.net bloggers

Filed under: General — arungupta @ 11:40 am

If you are a java.net blogger and blog about GlassFish then consider using “Community: GlassFish” category for any new entry as shown below:

All the consolidated blogs can then be read here. blogs.sun.com already makes it easy by providing tags, for example you can read all GlassFish blogs from Sun.

Here are some other related pointers for you:

  • TheAquarium
  • GlassFish for Business
  • All my GlassFish-related blogs

Technorati: java.net category glassfish

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

TOTD #35: Rails Database Connection on Solaris

Filed under: web2.0 — arungupta @ 12:02 am

Are you deploying your JRuby-on-Rails applications on Solaris (or any variety of Unix) and not able to connect to the database ?

I experienced it last week so thought of sharing the tip here. Luckily it’s really simple.

Here is the default generated “config/database.yml”

development:
  adapter: mysql
  encoding: utf8
  database: runner_development
  username: root
  password:
  socket: /tmp/mysql.sock

The only required change is to add “host: 127.0.01″ for the required database configuration. The updated fragment is shown below (with change highlighted):

development:
  adapter: mysql
  encoding: utf8
  database: runner_development
  username: root
  password:
  socket: /tmp/mysql.sock
  host: 127.0.01

Even though “host” is required for TCP connections but the database connection does not seem to work without this entry. The exact same application works without “host” entry on Windows and Mac OS.

Alternatively, you can always install the JDBC adapter as explained here.

Please leave suggestions on other TOTD (Tip Of The Day) that you’d like to see. A complete archive is available here.

Technorati: totd rubyonrails jruby ruby opensolaris mysql

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 20, 2008

TOTD #34: Using Felix Shell with GlassFish

Filed under: General — arungupta @ 6:45 am

TOTD #33 explains how to create a GlassFish v3 distribution that uses Apache Felix (default) as the  OSGi R4 Service Platform runtime. This blog explains how to use Felix Shell TUI with that bundle to issue commands to the OSGi framework and obtain information from it.

To enable Felix Shell with GlassFish v3, add the lines …

 ${com.sun.aas.installRootURI}/felix/bundle/org.apache.felix.shell.jar \
 ${com.sun.aas.installRootURI}/felix/bundle/org.apache.felix.shell.tui.jar

to “felix.auto.start.1″ property in “felix/conf/config.properties” file of the expanded bundle. The updated property looks like:

felix.auto.start.1= \
 ${com.sun.aas.installRootURI}/modules/tiger-types-osgi-0.3.2.jar \
 ${com.sun.aas.installRootURI}/modules/auto-depends-0.3.2.jar \
 ${com.sun.aas.installRootURI}/modules/config-0.3.2.jar \
 ${com.sun.aas.installRootURI}/modules/hk2-core-0.3.2.jar \
 ${com.sun.aas.installRootURI}/modules/osgi-adapter-0.3.2.jar \
 ${com.sun.aas.installRootURI}/felix/bundle/org.apache.felix.shell.jar \
 ${com.sun.aas.installRootURI}/felix/bundle/org.apache.felix.shell.tui.jar

with the changes highlighted in bold.

The shell works only if GlassFish is started using “java -jar modules/glassfish-10.0-SNAPSHOT.jar” command.

The shell is available when the following prompt is shown:

INFO: Glassfish v3 started in 1624 ms
Jun 16, 2008 7:10:37 PM  
INFO: ->
Jun 16, 2008 7:10:37 PM com.sun.enterprise.glassfish.bootstrap.ASMainFelix launchOSGiFW
INFO: Framework successfully started

You can type “help” in the shell to see the complete list of commands that are available:

help
Jun 16, 2008 7:11:12 PM  
INFO: bundlelevel <level> <id> … | <id> – set or get bundle start level.
Jun 16, 2008 7:11:12 PM  
INFO: cd [<base-URL>]                     – change or display base URL.
Jun 16, 2008 7:11:12 PM  
INFO: headers [<id> ...]                  – display bundle header properties.
Jun 16, 2008 7:11:12 PM  
INFO: help                                – display impl commands.
Jun 16, 2008 7:11:12 PM  
INFO: install <URL> [<URL> ...]           – install bundle(s).
Jun 16, 2008 7:11:12 PM  
INFO: packages [<id> ...]                 – list exported packages.
Jun 16, 2008 7:11:12 PM  
INFO: ps [-l | -s | -u]                   – list installed bundles.
Jun 16, 2008 7:11:12 PM  
INFO: refresh [<id> ...]                  – refresh packages.
Jun 16, 2008 7:11:12 PM  
INFO: resolve [<id> ...]                  – attempt to resolve the specified bundles.
Jun 16, 2008 7:11:12 PM  
INFO: services [-u] [-a] [<id> ...]       – list registered or used services.
Jun 16, 2008 7:11:12 PM  
INFO: shutdown                            – shutdown framework.
Jun 16, 2008 7:11:12 PM  
INFO: start <id> [<id> <URL> ...]         – start bundle(s).
Jun 16, 2008 7:11:12 PM  
INFO: startlevel [<level>]                – get or set framework start level.
Jun 16, 2008 7:11:12 PM  
INFO: stop <id> [<id> ...]                – stop bundle(s).
Jun 16, 2008 7:11:12 PM  
INFO: uninstall <id> [<id> ...]           – uninstall bundle(s).
Jun 16, 2008 7:11:12 PM  
INFO: update <id> [<URL>]                 – update bundle.
Jun 16, 2008 7:11:12 PM  
INFO: version                             – display version of framework.
Jun 16, 2008 7:11:12 PM  
INFO: -> 

This shows the list of available commands along with a brief description. For example “ps” shows the list of installed bundles as shown below:

ps
Jun 16, 2008 7:13:57 PM  
INFO: START LEVEL 1
Jun 16, 2008 7:13:57 PM  
INFO:    ID   State         Level  Name
Jun 16, 2008 7:13:57 PM  
INFO: [   0] [Active     ] [    0] System Bundle (1.0.4)
Jun 16, 2008 7:13:57 PM  
INFO: [   1] [Active   
  ] [    1] org.jvnet.tiger-types repackaged as module (0.3.2)

. . .
INFO: [ 137] [Installed  ] [    1] WebTier Security Integration (10.0.0.SNAPSHOT)
Jun 16, 2008 7:13:57 PM 
INFO: [ 138] [Installed  ] [    1] Web module command line interface (10.0.0.SNAPSHOT)
Jun 16, 2008 7:13:57 PM 
INFO: [ 139] [Installed  ] [    1] Admin GUI Web Container Plugin (10.0.0.SNAPSHOT)
Jun 16, 2008 7:13:57 PM 
INFO: ->

More details about the commands and options are available @ Felix Usage Docs.

The commands are described in “felix/conf/config.properties” (around line 38).

Please leave suggestions on other TOTD (Tip Of The Day) that you’d like to see. A complete archive is available here.

Technorati: totd glassfish v3 felix osgi

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 19, 2008

Interview with Sicilia JUG

Filed under: General — arungupta @ 11:45 pm


Sicilia JUG took my email interview a few days ago and published it on their website.

Read it here.

Thanks to Mario Cartia!

Technorati: sicilia jug interview

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 18, 2008

Rails 2.1 on GlassFish – it works!

Filed under: web2.0 — arungupta @ 11:45 pm

Rails 2.1 was released earlier this month. GlassFish provides a complete development/deployment environment for Rails applications. Some of the main reasons for using GlassFish (instead of WEBrick or Mongrel) are:

  • Identical Development and Deployment environment
  • Multiple Applications can be deployed on one Container
  • Multiple requests can be handled by a single application (with no extra configuration)
  • Out-of-the-box Clustering, Load Balancing and High Availability
  • Database connection pooling
  • Co-hosting Rails and Java EE applications

More details are available in Rails powered by the GlassFish Application Server. This blog provides detailed instructions to get started with Rails 2.1 on GlassFish.

  1. Install Rails 2.1 in a JRuby 1.1.2 installation:

    ~/testbed/rails21/jruby-1.1.2 >bin/jruby -S gem install rails –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 253 gems from http://gems.rubyforge.org/
    …………………………………………………………………….
    …………………………………………………………………….
    …………………………………………………………………….
    …………….
    complete
    Bulk updating Gem source index for: http://gems.rubyforge.org/
    Successfully installed activesupport-2.1.0
    Successfully installed activerecord-2.1.0
    Successfully installed actionpack-2.1.0
    Successfully installed actionmailer-2.1.0
    Successfully installed activeresource-2.1.0
    Successfully installed rails-2.1.0
    6 gems installed
  2. Create a new Rails app as:
    ~/testbed/rails21/jruby-1.1.2/samples/rails >../../bin/jruby -S rails -d mysql runner
          create  
          create  app/controllers
          create  app/helpers
          create  app/models
          create  app/views/layouts
          create  config/environments
          create  config/initializers
          create  db
          create  doc
          create  lib
          create  lib/tasks
          create  log
          create  public/images
          create  public/javascripts
          create  public/stylesheets
          create  script/performance
          create  script/process
          create  test/fixtures
          create  test/functional
          create  test/integration
          create  test/unit
          create  vendor
          create  vendor/plugins
          create  tmp/sessions
          create  tmp/sockets
          create  tmp/cache
          create  tmp/pids
          create  Rakefile
          create  README
          create  app/controllers/application.rb
          create  app/helpers/application_helper.rb
          create  test/test_helper.rb
          create  config/database.yml
          create  config/routes.rb
          create  config/initializers/inflections.rb
          create  config/initializers/mime_types.rb
          create  config/initializers/new_rails_defaults.rb
          create  config/boot.rb
          create  config/environment.rb
          create  config/environments/production.rb
          create  config/environments/development.rb
          create  config/environments/test.rb
          create  script/about
          create  script/console
          create  script/dbconsole
          create  script/destroy
          create  script/generate
          create  script/performance/benchmarker
          create  script/performance/profiler
          create  script/performance/request
          create  script/process/reaper
          create  script/process/spawner
          create  script/process/inspector
          create  script/runner
          create  script/server
          create  script/plugin
          create  public/dispatch.rb
          create  public/dispatch.cgi
          create  public/dispatch.fcgi
          create  public/404.html
          create  public/422.html
          create  public/500.html
          create  public/index.html
          create  public/favicon.ico
          create  public/robots.txt
          create  public/images/rails.png
          create  public/javascripts/prototype.js
          create  public/javascripts/effects.js
          create  public/javascripts/dragdrop.js
          create  public/javascripts/controls.js
          create  public/javascripts/application.js
          create  doc/README_FOR_APP
          create  log/server.log
          create  log/production.log
          create  log/development.log
          create  log/test.log
  3. Start GlassFish as:
    ~/testbed/glassfish/v3/tp2/glassfishv3-tp2/glassfish >java -DJRUBY_HOME=/Users/arungupta/testbed/rails21/jruby-1.1.2 -jar modules/glassfish-10.0-tp-2-SNAPSHOT.jar
    Jun 17, 2008 6:14:21 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    INFO: Launching GlassFish on HK2 platform
    Jun 17, 2008 6:14:22 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 8080
    Jun 17, 2008 6:14:22 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 8181
    Jun 17, 2008 6:14:22 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 4848
    Jun 17, 2008 6:14:22 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
    INFO: Admin Console Adapter: context root: /admin
    Jun 17, 2008 6:14:22 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 974 ms
  4. Deploy the newly created application as:
    ~/testbed/rails21/jruby-1.1.2/samples/rails >~/testbed/glassfish/v3/tp2/glassfishv3-tp2/glassfish/bin/asadmin deploy runner
    Command deploy executed successfully.

    and the GlassFish console shows:

    Jun 17, 2008 6:14:41 PM com.sun.enterprise.rails.RailsDeployer registerAdapter
    INFO: Loading application runner at /runner
    Jun 17, 2008 6:14:41 PM  
    INFO: Starting Rails instances
    Jun 17, 2008 6:14:49 PM  
    SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Jun 17, 2008 6:14:51 PM com.sun.grizzly.jruby.RubyObjectPool$1 run
    INFO: Rails instance instantiation took : 9066ms
    Jun 17, 2008 6:14:51 PM com.sun.enterprise.v3.deployment.DeployCommand execute
    INFO: Deployment of runner done is 9168 ms

    The default page at “http://localhost:8080/runner” shows

  5. Generate a Scaffold as described in TOTD #28
    ~/testbed/rails21/jruby-1.1.2/samples/rails/runner >../../../bin/jruby -S rake db:create
    (in /Users/arungupta/testbed/rails21/jruby-1.1.2/samples/rails/runner)
    ~/testbed/rails21/jruby-1.1.2/samples/rails/runner >../../../bin/jruby script/generate scaffold distance miles:float run_at:datetime
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
          exists  app/models/
          exists  app/controllers/
          exists  app/helpers/
          create  app/views/distances
          exists  app/views/layouts/
          exists  test/functional/
          exists  test/unit/
          exists  public/stylesheets/
          create  app/views/distances/index.html.erb
          create  app/views/distances/show.html.erb
          create  app/views/distances/new.html.erb
          create  app/views/distances/edit.html.erb
          create  app/views/layouts/distances.html.erb
          create  public/stylesheets/scaffold.css
          create  app/controllers/distances_controller.rb
          create  test/functional/distances_controller_test.rb
          create  app/helpers/distances_helper.rb
           route  map.resources :distances
      dependency  model
          exists    app/models/
          exists    test/unit/
          exists    test/fixtures/
          create    app/models/distance.rb
          create    test/unit/distance_test.rb
          create    test/fixtures/distances.yml
          create    db/migrate
          create    db/migrate/20080618012326_create_distances.rb
    ~/testbed/rails21/jruby-1.1.2/samples/rails/runner >../../../bin/jruby -S rake db:migrate
    (in /Users/arungupta/testbed/rails21/jruby-1.1.2/samples/rails/runner)
    == 20080618012326 CreateDistances: migrating ==================================
    — create_table(:distances)
       -> 0.0080s
    == 20080618012326 CreateDistances: migrated (0.0090s) =========================
  6. Edit line 44 of “config/environment.rb” to change the default timezone from “UTC” to “Pacific Time (US & Canada)”. The updated line looks like:
      config.time_zone = ‘Pacific Time (US & Canada)’
  7. Creating a new scaffold entry shows the following screen:

    Notice how default timezone is selected using Rails 2.1 Time Zone Support. After creating couple of entries (as described in TOTD #28), the page at “http://localhost:8080/runner/distances” looks like:

    Notice how “-0700″ is shown which is the offset for US Pacific Time during daylight savings.

The same application can also be easily deployed on GlassFish v3 Gem. Let’s see how:

  1. Install GlassFish v3 Gem as:

    ~/testbed/rails21/jruby-1.1.2 >bin/jruby -S gem install glassfish
    JRuby limited openssl loaded. gem install jruby-openssl for full support.

    e="font-family: monospace;">http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL

    Updating metadata for 13 gems from http://gems.rubyforge.org/
    ………….
    complete
    Successfully installed glassfish-0.2.0-universal-java
    1 gem installed
  2. Deploy the previously created Rails application as:
    ~/testbed/rails21/jruby-1.1.2/samples/rails >../../bin/jruby -S glassfish_rails runner
    Jun 17, 2008 6:39:37 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    INFO: Launching GlassFish on HK2 platform
    Jun 17, 2008 6:39:37 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient
    INFO: Cannot find javadb client jar file, jdbc driver not available
    Jun 17, 2008 6:39:38 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3000
    Jun 17, 2008 6:39:38 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
    WARNING: pewebcontainer.all_ssl_protocols_disabled
    Jun 17, 2008 6:39:38 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
    WARNING: pewebcontainer.all_ssl_ciphers_disabled
    Jun 17, 2008 6:39:38 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3131
    Jun 17, 2008 6:39:38 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3838
    Jun 17, 2008 6:39:39 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
    INFO: Admin Console Adapter: context root: /admin
    Jun 17, 2008 6:39:39 PM com.sun.enterprise.rails.RailsDeployer registerAdapter
    INFO: Loading application runner at /
    Jun 17, 2008 6:39:39 PM 
    INFO: Starting Rails instances
    Jun 17, 2008 6:39:44 PM 
    SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Jun 17, 2008 6:39:45 PM com.sun.grizzly.jruby.RubyObjectPool$1 run
    INFO: Rails instance instantiation took : 6710ms
    Jun 17, 2008 6:39:45 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 8053 ms

    The page at “http://localhost:3000/runner” looks like:

Let us know on GlassFish Webtier Forum or Webtier Alias if you tried any of your Rails application on GlassFish. Please file bugs at GlassFish Issue Tracker (“V3″ as “Found in Version:” and “jruby” as “Subcomponent:”) if your app is not working.

Technorati: glassfish v3 rubyonrails jruby ruby gem

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Older Posts »

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress