Skip to main content

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

Posted by arungupta on June 30, 2008 at 11:03 AM PDT


cellspacing="5">
style="border: 0px solid ; width: 260px; height: 71px;" alt=""
src="http://blogs.sun.com/arungupta/resource/ror/substruct-logo.png">
Substruct
is an open-source E-Commerce project written using href="http://rubyonrails.org/">Ruby-on-Rails
framework. It provides a simple e-commerce platform, content management
system and customer response system - href="http://code.google.com/p/substruct/wiki/ThoughtsBehindSubstruct">all
in one.





I found out about this application from href="http://javapassion.com/">Sang "Passion" Shin's
Lab
5542
(part of href="http://blogs.sun.com/arungupta/entry/free_20_week_ruby_on">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 href="http://rubyforge.org/projects/glassfishgem/">GlassFish
v3 Gem. The GlassFish Gem installation is described
here.

  1. href="http://code.google.com/p/substruct/downloads/list">Download
    and install Substruct


    cellpadding="2" cellspacing="2">
    ~/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


    cellpadding="2" cellspacing="2">
    ~/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


    cellpadding="2" cellspacing="2">
    ~/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


    cellpadding="2" cellspacing="2">
    ~/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:


    cellpadding="2" cellspacing="2">
    ~/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



href="http://blogs.sun.com/arungupta/resource/ror/v3gem-substruct-welcome.png"> style="border: 0px solid ; width: 700px; height: 544px;" alt=""
src="http://blogs.sun.com/arungupta/resource/ror/v3gem-substruct-welcome.png">



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


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



The modified view looks like as shown below:



href="http://blogs.sun.com/arungupta/resource/ror/v3gem-substruct-line36.png"> style="border: 0px solid ; width: 700px; height: 71px;" alt=""
src="http://blogs.sun.com/arungupta/resource/ror/v3gem-substruct-line36.png">



The updated output looks like:



href="http://blogs.sun.com/arungupta/resource/ror/v3gem-substruct-with-gf-logo.png"> style="border: 0px solid ; width: 700px; height: 554px;" alt=""
src="http://blogs.sun.com/arungupta/resource/ror/v3gem-substruct-with-gf-logo.png">



I
tried only the basic deployment and that seem to work. If you try
slightly more advanced usecases then the functionality provided by href="http://wiki.rubyonrails.org/rails/pages/RedCloth">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, href="https://glassfish.dev.java.net/issues/enter_bug.cgi?issue_type=DEFECT">file
bugs here with "jruby" as "subcomponent" (default version is
"v3").



Also check out href="http://blogs.sun.com/arungupta/entry/redmine_on_glassfish_ruby_on">Redmine href="http://blogs.sun.com/arungupta/entry/redmine_on_glassfish_ruby_on">
on GlassFish v3.



Technorati: href="http://technorati.com/tag/rubyonrails">rubyonrails
glassfish
netbeans
substruct
webtier

Related Topics >>