SlideShare a Scribd company logo
Getting Started with
Rails on GlassFish
(Hands-on Lab)




Arun Gupta, Java EE & GlassFish Guy,
Oracle Corp
blogs.sun.com/arungupta, @arungupta
What this session is not ?

• Not a GlassFish tutorial
• Not a Rails tutorial
• Not a MySQL tutorial
Software Installed ?

• JDK 1.6.0_XX
• NetBeans 6.8 (“All” or “Ruby” bundle)
• JRuby 1.4.0
• MySQL Community Server




                                 15 minutes
What is GlassFish ?
What is GlassFish ?
GlassFish: It's a Community!
GlassFish: Lives on java.net




   Since 2005
GlassFish: Open Source and
Production Quality
GlassFish: Reference Implementation



          Java EE 5
          Java EE 6
GlassFish v3
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
What is Ruby-on-Rails ?

• Full-stack Web development framework in
 Ruby
 • Popularly known as Rails
• Current Version: Rails 2.3.5
  • Rails 3.0 coming
Ruby-on-Rails MVC
                                  Incoming
                                  Request



                        Web Server
                    ActionController
                      (Controller)


ActiveRecord                                 ActionView
                        xxx_controller.rb
  (Model)                                      (View)


               xxx.rb                        .rhtml   .erb
Database
Rails Design Principles

• Convention over Configuration (CoC)
  • Common cases easily served
  • Encourages standard practices
  • Everything simpler and smaller
• Don't Repeat Yourself (DRY)
  • Framework written around minimizing repetition
• Agile Development
  • No compile, redeploy, restart cycles
  • Testing built into the framework
JRuby
• Ruby interpreter written in Java
• Current Version: 1.4.0
  • 1.5 RC coming soon
• Ruby 1.8.7 compatible
• Some Ruby 1.9 support
  • --1.9 flag (80%)
JRuby
• Solid performance ( ͋Ruby 1.9)
  • Startup is poor, execution usually better than
    1.9
• Runs native threads
• Foreign Function Interface (FFI)for C
 libraries
  • Adopted from Rubinius, CRuby gem
• Runs Rails great!
Install JRuby

• CLI: Download & Unzip “jruby-
 bin-1.4.0.zip” from jruby.org

• NetBeans “All” or “Ruby” bundle
 (pre-installed)
Install Rails & GlassFish Gem

• CLI: “jruby -S gem install rails
 glassfish”

• NetBeans: Tools -> Ruby Gems
 -> New Gems
 • Rails pre-installed
 • Search “glassfish”, Install   5 minutes
Start Database

• Mac/Linux: mysqld_safe --user
root

• Windows: bin/mysqld-nt --user
root
 • Installed as service ?
                            2 minutes
Install Database Adapter


“jruby -S gem install
activerecord-jdbcmysql-adapter”




                            2 minutes
Create a Rails App


jruby -S rails helloworld -d mysql
cd helloworld
jruby script/generate jdbc
jruby -S rake db:create

                           5 minutes
Run the App

cd helloworld
jruby -S glassfish




                     5 minutes
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Add CRUD features

jruby script/generate scaffold
   book title:string author:string




                            5 minutes
Model View Controller
      exists app/models/
      exists app/controllers/
      exists app/helpers/
      create app/views/books
      exists app/views/layouts/
      exists test/functional/
      exists test/unit/
      create test/unit/helpers/
      exists public/stylesheets/
      create app/views/books/index.html.erb
      create app/views/books/show.html.erb
      create app/views/books/new.html.erb
      create app/views/books/edit.html.erb
      create app/views/layouts/books.html.erb
      create public/stylesheets/scaffold.css
      create app/controllers/books_controller.rb
      create test/functional/books_controller_test.rb
      create app/helpers/books_helper.rb
      create test/unit/helpers/books_helper_test.rb
       route map.resources :books
    dependency model
      exists app/models/
      exists test/unit/
      exists test/fixtures/
      create app/models/book.rb
      create test/unit/book_test.rb
      create test/fixtures/books.yml
      create db/migrate
      create db/migrate/20100310221044_create_books.rb
Generate Database Table

   jruby -S rake db:migrate

== CreateBooks: migrating ============================
-- create_table(:books)
   -> 0.1690s
   -> 0 rows
== CreateBooks: migrated (0.1710s) =====================

                                        2 minutes
Sample Output




                5 minutes
GlassFish Gem




 http://rubyforge.org/projects/glassfishgem/
GlassFish Gem: Options


 jruby -S glassfish -h

 -c: change the context root
 -e: environment
 -d: runs as daemon
 -P: location of PID file
 -l: log file location
 -log-level: Logging level (0-7)
GlassFish Gem: Recipes
Why Rails on GlassFish ? - Agile
Why ? - Easy prototyping, yet powerful
Why ? - Best of both worlds
Why ? - Database Connection Pooling
Why ? - Management
Why ? - Monitoring
Directory-based deployment: How ?


asadmin start-domain
asadmin deploy
   --property "jruby.home=JRUBY_HOME"
   helloworld

                              Complete
                              Absolute
                                Path


                             7 minutes
Directory-based deployment: Recipes
Not Just Rails ...




http://blogs.sun.com/arungupta/entry/totd_53_scaffold_in_merb
http://blogs.sun.com/arungupta/entry/totd_80_sinatra_crud_application
And more ...




http://weblogs.java.net/blog/vivekp/archive/2009/04/plugin_any_ruby.html
Deployment Options




http://blogs.sun.com/arungupta/entry/totd_81_how_to_use
http://blog.headius.com/2009/04/apache-jruby-rails-glassfish-easy.html
Rails on GlassFish: WAR Deployment
WAR Deployment: How ?




 jruby -S gem install warbler
 jruby -S warble
 asadmin deploy xxx.war


                                                    7 minutes
http://blogs.sun.com/arungupta/entry/totd_73_jruby_and_glassfish
WAR Deployment: How in NetBeans ?
WAR Deployment: Packaging
Rails on GlassFish: Update Center
NetBeans: Develop with Pleasure




                                                     10 minutes
http://blogs.sun.com/arungupta/entry/screencast_26_develop_run_debug
Rails Monitoring

• Basic Monitoring
 •   jinfo: System properties and VM CLI flags
 •   jmap: Shared object memory map
 •   jstack: Stack traces of Java threads
 •   jstat: Performance statistics on class, JIT compiler, GC, ...
• Advanced
 • jconsole / Visual VM
 • NewRelic, FiveRuns, ...
jConsole




      http://blogs.sun.com/arungupta/tags/rubyonrails+jmx
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Turbo charging your JRuby Startup

• “-client” or “-server” ? (Upto 50%)
   • Faster startup or solid runtime ?
   • export JAVA_OPTS=”-client -D32”
   • Upto 50% improvement
• For Linux: Class Data Sharing
• Delay or disable JRuby's JIT (Upto 10%)
   • -X-C
   • jruby.compile.mode=OFF
• Avoid spawning “sub-Rubies”
• Nailgun for small JRuby CLI invocations
• Favorite JVM Flags
Who loves Rails on GlassFish ?
Resources

• glassfish.org
• blogs.sun.com/theaquarium
• glassfish-scripting.dev.java.net
• wiki.glassfish.java.net/Wiki.jsp?
  page=JRuby
• blogs.sun.com/arungupta

More Related Content

PDF
Powering the Next Generation Services with Java Platform - Spark IT 2010
Arun Gupta
 
PDF
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Arun Gupta
 
PDF
Running your Java EE 6 applications in the Cloud
Arun Gupta
 
PDF
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
Arun Gupta
 
PDF
Running your Java EE applications in the Cloud
Arun Gupta
 
PDF
GlassFish & Java EE Business Update @ CEJUG
Arun Gupta
 
PDF
Java Summit Chennai: JAX-RS 2.0
Arun Gupta
 
PDF
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
Arun Gupta
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Arun Gupta
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Arun Gupta
 
Running your Java EE 6 applications in the Cloud
Arun Gupta
 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
Arun Gupta
 
Running your Java EE applications in the Cloud
Arun Gupta
 
GlassFish & Java EE Business Update @ CEJUG
Arun Gupta
 
Java Summit Chennai: JAX-RS 2.0
Arun Gupta
 
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
Arun Gupta
 

What's hot (20)

PDF
GlassFish v3 at JavaZone 09
Alexis Moussine-Pouchkine
 
PDF
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Arun Gupta
 
PPTX
Java EE 8
Ryan Cuprak
 
PDF
Keith Larson Replication
Dave Stokes
 
PDF
Java EE 6 = Less Code + More Power
Arun Gupta
 
PDF
Java EE 6 Aquarium Paris
Alexis Moussine-Pouchkine
 
PDF
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Marakana Inc.
 
PDF
JFokus 2011 - Running your Java EE 6 apps in the Cloud
Arun Gupta
 
PDF
Glass Fishv3 March2010
Stephan Janssen
 
PDF
20151010 my sq-landjavav2a
Ivan Ma
 
PDF
Sun Java EE 6 Overview
sbobde
 
PDF
WildFly v9 - State of the Union Session at Voxxed, Istanbul, May/9th 2015.
Dimitris Andreadis
 
PDF
JBoss EAP / WildFly, State of the Union
Dimitris Andreadis
 
PDF
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
PDF
Java EE 6 Component Model Explained
Shreedhar Ganapathy
 
PDF
Understanding
Arun Gupta
 
PDF
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Skills Matter
 
PDF
RESTful web service with JBoss Fuse
ejlp12
 
PDF
GlassFish v3 Prelude Aquarium Paris
Alexis Moussine-Pouchkine
 
PDF
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Arun Gupta
 
GlassFish v3 at JavaZone 09
Alexis Moussine-Pouchkine
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Arun Gupta
 
Java EE 8
Ryan Cuprak
 
Keith Larson Replication
Dave Stokes
 
Java EE 6 = Less Code + More Power
Arun Gupta
 
Java EE 6 Aquarium Paris
Alexis Moussine-Pouchkine
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Marakana Inc.
 
JFokus 2011 - Running your Java EE 6 apps in the Cloud
Arun Gupta
 
Glass Fishv3 March2010
Stephan Janssen
 
20151010 my sq-landjavav2a
Ivan Ma
 
Sun Java EE 6 Overview
sbobde
 
WildFly v9 - State of the Union Session at Voxxed, Istanbul, May/9th 2015.
Dimitris Andreadis
 
JBoss EAP / WildFly, State of the Union
Dimitris Andreadis
 
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
Java EE 6 Component Model Explained
Shreedhar Ganapathy
 
Understanding
Arun Gupta
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Skills Matter
 
RESTful web service with JBoss Fuse
ejlp12
 
GlassFish v3 Prelude Aquarium Paris
Alexis Moussine-Pouchkine
 
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Arun Gupta
 
Ad

Similar to Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010 (20)

PDF
Dynamic Languages & Web Frameworks in GlassFish
IndicThreads
 
ODP
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
PDF
GlassFish can support multiple Ruby frameworks ... really ?
Arun Gupta
 
PDF
Glass fish rubyconf-india-2010-Arun gupta
ThoughtWorks
 
PDF
GlassFish and NetBeans: Develop with pleasure, Deploy with Fun for a better R...
Arun Gupta
 
PDF
Scripting Support in GFv3 Prelude - Full Version
Eduardo Pelegri-Llopart
 
PDF
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
railsconf
 
PDF
JRuby - Programmer's Best Friend on JVM
Raimonds Simanovskis
 
PDF
JRuby, Ruby, Rails and You on the Cloud
Hiro Asari
 
KEY
Ruby on Rails survival guide of an aged Java developer
gicappa
 
PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
PDF
A jar-nORM-ous Task
Erin Dees
 
PDF
JRuby on Rails Deployment: What They Didn't Tell You
elliando dias
 
KEY
Why ruby and rails
Reuven Lerner
 
PDF
Devoxx%202008%20Tutorial
tutorialsruby
 
PDF
Devoxx%202008%20Tutorial
tutorialsruby
 
PDF
JRuby and Google App Engine
joshsmoore
 
PDF
Ruby projects of interest for DevOps
Ricardo Sanchez
 
PDF
Ricardo Sanchez - Ruby projects of interest for devops
SVDevOps
 
PDF
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Dynamic Languages & Web Frameworks in GlassFish
IndicThreads
 
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
GlassFish can support multiple Ruby frameworks ... really ?
Arun Gupta
 
Glass fish rubyconf-india-2010-Arun gupta
ThoughtWorks
 
GlassFish and NetBeans: Develop with pleasure, Deploy with Fun for a better R...
Arun Gupta
 
Scripting Support in GFv3 Prelude - Full Version
Eduardo Pelegri-Llopart
 
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
railsconf
 
JRuby - Programmer's Best Friend on JVM
Raimonds Simanovskis
 
JRuby, Ruby, Rails and You on the Cloud
Hiro Asari
 
Ruby on Rails survival guide of an aged Java developer
gicappa
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
A jar-nORM-ous Task
Erin Dees
 
JRuby on Rails Deployment: What They Didn't Tell You
elliando dias
 
Why ruby and rails
Reuven Lerner
 
Devoxx%202008%20Tutorial
tutorialsruby
 
Devoxx%202008%20Tutorial
tutorialsruby
 
JRuby and Google App Engine
joshsmoore
 
Ruby projects of interest for DevOps
Ricardo Sanchez
 
Ricardo Sanchez - Ruby projects of interest for devops
SVDevOps
 
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Ad

More from Arun Gupta (20)

PDF
5 Skills To Force Multiply Technical Talents.pdf
Arun Gupta
 
PPTX
Machine Learning using Kubernetes - AI Conclave 2019
Arun Gupta
 
PDF
Machine Learning using Kubeflow and Kubernetes
Arun Gupta
 
PPTX
Secure and Fast microVM for Serverless Computing using Firecracker
Arun Gupta
 
PPTX
Building Java in the Open - j.Day at OSCON 2019
Arun Gupta
 
PPTX
Why Amazon Cares about Open Source
Arun Gupta
 
PDF
Machine learning using Kubernetes
Arun Gupta
 
PDF
Building Cloud Native Applications
Arun Gupta
 
PDF
Chaos Engineering with Kubernetes
Arun Gupta
 
PDF
How to be a mentor to bring more girls to STEAM
Arun Gupta
 
PDF
Java in a World of Containers - DockerCon 2018
Arun Gupta
 
PPTX
The Serverless Tidal Wave - SwampUP 2018 Keynote
Arun Gupta
 
PDF
Introduction to Amazon EKS - KubeCon 2018
Arun Gupta
 
PDF
Mastering Kubernetes on AWS - Tel Aviv Summit
Arun Gupta
 
PDF
Top 10 Technology Trends Changing Developer's Landscape
Arun Gupta
 
PDF
Container Landscape in 2017
Arun Gupta
 
PDF
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Arun Gupta
 
PDF
Docker, Kubernetes, and Mesos recipes for Java developers
Arun Gupta
 
PDF
Thanks Managers!
Arun Gupta
 
PDF
Migrate your traditional VM-based Clusters to Containers
Arun Gupta
 
5 Skills To Force Multiply Technical Talents.pdf
Arun Gupta
 
Machine Learning using Kubernetes - AI Conclave 2019
Arun Gupta
 
Machine Learning using Kubeflow and Kubernetes
Arun Gupta
 
Secure and Fast microVM for Serverless Computing using Firecracker
Arun Gupta
 
Building Java in the Open - j.Day at OSCON 2019
Arun Gupta
 
Why Amazon Cares about Open Source
Arun Gupta
 
Machine learning using Kubernetes
Arun Gupta
 
Building Cloud Native Applications
Arun Gupta
 
Chaos Engineering with Kubernetes
Arun Gupta
 
How to be a mentor to bring more girls to STEAM
Arun Gupta
 
Java in a World of Containers - DockerCon 2018
Arun Gupta
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
Arun Gupta
 
Introduction to Amazon EKS - KubeCon 2018
Arun Gupta
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Arun Gupta
 
Top 10 Technology Trends Changing Developer's Landscape
Arun Gupta
 
Container Landscape in 2017
Arun Gupta
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Arun Gupta
 
Docker, Kubernetes, and Mesos recipes for Java developers
Arun Gupta
 
Thanks Managers!
Arun Gupta
 
Migrate your traditional VM-based Clusters to Containers
Arun Gupta
 

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
AbdullahSani29
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
georgschmitzdoerner
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
PDF
NewMind AI Monthly Chronicles - July 2025
NewMind AI
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
DOCX
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Shreyas_Phanse_Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
SHREYAS PHANSE
 
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
AbdullahSani29
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
madgavkar20181017ppt McKinsey Presentation.pdf
georgschmitzdoerner
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
NewMind AI Monthly Chronicles - July 2025
NewMind AI
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Doc9.....................................
SofiaCollazos
 
Shreyas_Phanse_Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
SHREYAS PHANSE
 
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
Software Development Company | KodekX
KodekX
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 

Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010