Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.
« Previous page | Main | Next page »

http://blogs.sun.com/arungupta/date/20091015 Thursday October 15, 2009

Oracle Open World 2009 – Day 4 with Larry, Arnold , and Aerosmith

Day 4 of Oracle Open World 2009 (Day 1, Day 2, Day 3) was all about about spending time at the Java EE 6 exhibit, attending Larry's keynote and finally the Appreciation Event.

Larry talked about Oracle Enterprise Linux, Exadata v2, Oracle Enterprise Manager, and Fusion Apps.

Exadata v2 runs Oracle database faster than any other machine on the planet. With Exadata v1, the advantages were pretty obvious with customers reducing query times from 24 hours to 30 mins and 30 min to 1 min and some observing 10x - 72x improvements. Exadata v2 is much faster and bigger than v1 with 400 GB of DRAM + 5 TB of flash gives spectacular random IO memory (1 million I/Os per second).

Arnold Schwarzenegger made a surprise appearance during Larry's keynote to talk about the technology innovation. Watch him speak in the 2-part videos below:

Watch Arnold's endorsement of Oracle/Sun merger starting at 1:15 in part 2 video above.

This was my first experience to watch Arnold speaking live at a conference and must say I was truly impressed, and feel honored, by our esteemed governor. He is a great business men who did not deter from the opportunity to sell "Kaalifornia" to all the conference attendees. And he still very much carry the charm & persona from his previous life as a superstar.

The Appreciation Event had an impressive lineup of rocks bands including Aerosmith and Roger Daltrey. There was a boardwalk carnival with Ferris wheel, thrill rides and a games arcade. And of course there were exotic treats to feed you. One thing was clear, Oracle certainly knows how to take care of their customers!

Here are some pictures from yesterday:

And the complete album at:



After attending Oracle Open World 2009 for four days, I'm more than eagerly waiting for the merger to complete now. Now whether they keep me or not, I'm confident that they'll be able to turn Sun around and make money out of it. If they keep me, I'm part of that success. If not, I'll get job elsewhere but at least will be happy to see Sun's products generating revenue :-)

Cmon EU!

Technorati: conf oracle openworld oow glassfish javaee otn bloggers arnold


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

http://blogs.sun.com/arungupta/date/20091013 Tuesday October 13, 2009

Oracle Open World 2009 – Day 3 Report

Day 3 of Oracle Open World 2009 (Day 1, Day 2) started on an adventurous note for me. The San Francisco Bay Area got hit with the strongest October storm in 47 years and so the ride from home to Moscone Center took almost 30 extra minutes, because of flooded roads, strong winds, other accidents, and hydroplaning multiple times. Anyway only missed first few minutes of Thomas Kurian's keynote. Kurian is no stranger to the Java crowd because he is a regular keynote speaker at JavaOne. However it was totally impressive to see customer endorsements (both quality and quantity) and how they are using Oracle to solve operational problems.

Some more observations from the floor:

  • The last session gets over at 6:30pm and Moscone halls are closed after that, no late night BoFs or AfterDark events.
  • The game lounge is in the Moscone West only, not sure why. May be because that's where the Middleware stream is and that's where the developers are attracted ;-)
  • There is a dedicated slots for Exhibitor Hall where no other formal activities are happening.

I spent some time on the Java EE 6 booth talking about the technology and showcasing GlassFish features such as monitoring and Rails deployment.

Enjoy videos of marketing gimmicks by some vendors at the show floor:

The evening ended with the OOW Bloggers Meetup at LJ's Martini Club & Grill. It was good to meet fellow bloggers from Oracle and other companies. OTN folks arranged a game to promote social networking. Basically, everybody was given a tee-shirt to wear and whoever has the most signatures from other bloggers wins an HP notebook. A MacBook would've been a better incentive to compete for me ;-) Anyway there was beer and muchies to keep the bloggers happy. Thanks to Justin (aka "King of OTN") for picking the bill!

Here are some pictures from earlier today:

And the evolving album at:



If you are not able to attend in person, then you can follow OOW Blogs, Open World Live, @OpenWorld (twitter), Community tweets with #oow.

Looking forward to see Arnold Schwarzenegger discussing technology innovation with Larry Ellison tomorrow.

Technorati: conf oracle openworld oow glassfish javaee otn bloggers


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

Hudson Webinar and Q&A – 10/14, 10am PT

Koshuke (aka "Mr Hudson") is giving a webinar and a live Q&A session on Hudson tomorrow.

Please register now!

Technorati: glassfish hudson webinar

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

http://blogs.sun.com/arungupta/date/20091012 Monday October 12, 2009

Oracle Open World 2009 - Day 2 Report

Following from Day 1, the Day 2 started with Charles Phillips and Safra Catz keynote. The keynotes at Open World are significantly different from JavaOne or any other developer conference I've attended so far. Of course they are expected to be because Open World is not primarily a developer's conference. Oracle Develop (OD) certainly closely mimic any of the conferences I've typically attended. My "exhibitor" badge restricted me from attending any of the sessions at OD though :-(

Here are some interesting statistics about the conference:

5 content streams (Database, Applications, Industries, Management & Infrastructure, & Middleware)
314 demo kisosk
401 partners & customer exchibiting
1966 educational sessions (10% more than last year)
4500 Oracle developers/experts for you
81,266 hotel room nights
170,000 cups of coffee
182,000 online participation

Here are some interesting sightings from the Open World exhibitor pavilion:

  • Tata Consultancy Services, Infosys, HCL, Wipro, Mahindra Satyam, Birlasoft, Cognizant and a host of other companies based in India are exhibiting in the pavilion. This is a pleasant surprise from JavaOne which typically does not see these many companies out of India.
  • Poker, Ducati, Glider, Beatles Guitar, Sumo wrestler, Callaway Golf, Mini Cooper and other similar sightings were spotted. Check out complete set of images here.
  • Lot more attendees are wearing a suit, quite unlike JavaOne or RailsConf which is typically denim/t-shirt rich.

On a personal front, everything that possibly could went wrong as part of the demo installation yesterday and rehearsal for my talks earlier today. NetBeans was not able to connect to the Oracle database (couple of machine restarts solved that), GlassFish Tools Bundle for Eclipse was timing out attempting to start GlassFish (removing workspace solved that problem), NetBeans's RESTful tooling not recognizing JPA entities, and also found a blocking bug (issue #10166) in deploying Rails app to latest GlassFish promoted build. These demos have worked seamlessly for me all the time time and fortunately worked well during the talk.

My talk at the Unconference on Creating Quick and Powerful Web applications with Oracle, GlassFish and NetBeans/Eclipse went well. It was truly an unconference event with no projector or mic in the presentation room. But the small attendance allowed us to huddle around the table and luckily all the demos worked seamlessly. The slides are available at:

Several demos shown in the talk are available at:

The slides have pointers to several other demos as well. Also showed the simplicity of Java EE 6 development using Eclipse in Java Platform, Enterprise Edition: The Foundation and Future of Your Enterpise.

The day concluded with OTN Night in Howard St tent. Check out a brief video from the event:

Here are some pictures from earlier today:

And the evolving album at:



If you are not able to attend in person, then you can follow OOW Blogs, Open World Live, @OpenWorld (twitter), Community tweets with #oow.

Back tomorrow on Day 3 with more pictures :-)

Technorati: conf oracle openworld oow glassfish javaee netbeans eclipse


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

http://blogs.sun.com/arungupta/date/20091011 Sunday October 11, 2009

Oracle Open World 2009 - Day 1 Report

Sun Microsystems is the innovation sponsor of Oracle Open World 2009. And that's what was the theme of Scott McNealy's keynote on a "Sun"day. It's been a while that I've seen Scott on the keynote stage and it truly was an enjoyable experience. In his characteristic way, he gave top 10 reasons that "Engineers have gone wild" as:

10. Who needs thumb drive in the shape of sushi ?
9. "Noble prize" recently awards for gas mask bra - no more ridiculous than other noble prizes recently awarded
8. OS/2
7. Patent awarded for face mask with voice modification capability
6. I could do an entire top 10 of worlds strangest keyboards (strangest being iPhone, "Friends don't let friends type on iPhone")
5. Windows 7
4. Man uses SPARCstation for his ashses
3. New market in "family size' plots
2. Mainframe running Linux
1. Some one came up with this crazy idea for a 'Java Ring'

And then on a more serious note, and keeping with the keynote theme, top 10 innovations from Sun:

10. NFS/PC-NFS Technology (1983)
9. SPARC (1989)
8. Open Source Software (Berkeley Unix, "Red Hat of Berkeley Unix", #1 contributor to OSS community)
7. BSD + UNIX System 5 = Solaris
6. Java (Java card, EE/SE/ME, JavaFX)
5. E10K (64-way Solaris, no longer mainframe required)
4. ZFS/Open Storage/Flash (Exadata)
3. Project Blackbox, world's first modular datacenter
2. SunRay
1. Chip multithreading "CoolThreads"

And the biggest innovation from Sun:

Kicked Butt
Had Fun
Didn't CHeat
Loved our customers
Changed computing for ever

Scott explained why SPARC, Solaris, MySQL, Java are here to stay. "Kick Butt, Have Fun" is truly the spirit at Sun :-)

James Gosling, the father of Java, showed up on the stage to talk about Java's relevance for Oracle. Also showed "The Gospel of Java according to James" and the video is shown below:

John Fowler talked about several brand new Sun/Oracle world-record benchmarks. A key point from these benchmarks "Oracle and Sun were able to set the world record using 1/8th the hardware that IBM used for its largest benchmark". And we also announced F5100 Flash Array, the world's fastest solid-state flash array.

And here are some quotes from Larry Ellison's keynote appearance:

  • "SPARC is a fantastic technology"
  • "All Oracle software runs reliably and faster on Solaris, than ever before"
  • "MySQL competes in different market", "We are going to spend more, not less, on MySQL", "Increase our rate of contribution to that product"
  • "Not only invest in Sun technology, also in Sun business"
  • IBM: Slower, Costs More, Not Fault Tolerant, Not Very Green (from a slide)
  • 25% more throughput, (can do lot better), 16x better response time
  • "IBM's processor is called "POWER", we know why ?" (because it's consumes the entire power of your data center ;-)
  • "I'm not fair on IBM because they are not here to respond"
  • One mans' SUNset is another man's SUNrise, We think this is SUNrise time"

It totally reminded me of Scott McNealy's "dot-not" (as compared to .NET) and "c-flat" (for C#) quotes from JavaOne :-)

Check out related articles about Sun's presence at Open World:

Here are some pictures:

And the evolving album at:



If you are not able to attend in person, then you can follow OOW Blogs, Open World Live, @OpenWorld (twitter), Community tweets with #oow.

On a personal note, this is my first Open World and am totally amazed by the size of attendees, and it's only a Sunday. The entire Howard St is shutdown and tents are installed to accommodate the conference. All 3 Moscone halls (North, South, and West) are used. A scale down replica of Larry's "Rising Sun" is also displayed on Howard Street. And for the first time in 10 years, I'm getting only an Exhibitor badge at Moscone :-)

Also installed GlassFish, NetBeans/Eclipse demos on the booth machine and ready to wow the audience with Java EE 6 in the exhibitor hall for the next 3 days! And of course, I'm talking at the Unconference tomorrow at 11am on Creating Quick and Powerful Web applications with Oracle, GlassFish and NetBeans/Eclipse. Get ready to see lots and lots of demos!

Back tomorrow with more pictures :-)

Technorati: conf oracle openworld oow glassfish netbeans eclipse


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

http://blogs.sun.com/arungupta/date/20091008 Thursday October 08, 2009

TOTD #112: Exposing Oracle database tables as RESTful entities using JAX-RS, GlassFish, and NetBeans

This Tip Of The Day explains how to expose an existing Oracle database table as a RESTful Web service endpoint using NetBeans tooling and deployed on GlassFish.

Lets get started!

  1. Configure GlassFish v3 10/7 or a later nightly in a recent NetBeans 6.8 build (latest nightly). As issue# 9885 is fixed, so copy ojdbc6.jar in the "domains/domain1/lib/ext" directory.
  2. Create a Web application
    1. Create a new "Web application" and name the project "RestfulOracle":



      click on "Next >".
    2. Choose the newly added server and "Java EE 6 Web" as the Java EE version:



      and click on "Finish".
  3. Create JPA entities for "HR" schema. The steps outlined below uses NetBeans solely for creating the JPA entities. Alternatively, TOTD #108 explains how to define a JDBC connection pool and JDBC resource using "asadmin" CLI and then use that resource from within NetBeans. Either way, the JDBC resource is stored in the underlying "domain.xml".
    1. Right-click on the project and select "New", "Entity Classes from Database...".
    2. In "Data Source:" select "New Data Source..." as shown below:

    3. Specify the JNDI name as "jdbc/hr" and choose the pre-configured database connection as shown below:



      TOTD #107 explains how to configure Oracle database in NetBeans.
    4. In the list of "Available Tables:", select "EMPLOYEES" and click on "Add >" to see the following:



      Notice the list of related tables are included as well. Click on "Next >".
    5. Specify the package name as "model".
    6. Click on "Create Persistence Unit...", take the defaults, and click on "Create":



      and click on "Finish". Notice EclipseLink, the reference implementation for JPA 2.0, is used as the persistence provider. This generates POJOs that provide database access using JPA 2.0 APIs. These APIs are included as part of the Java EE 6 platform.
  4. Create RESTful entities
    1. Right-click on the project and select "RESTful Web Services from Entity Classes...":


    2. Select "Employees (model.Employees)" from "Available Entity Classes:" and click on "Add >" to see the following:



      click on "Next >", take the defaults, and click on "Finish". This generates a bunch of wrapper classes using JAX-RS to expose the JPA Entity classes as RESTful Web services. JAX-RS 1.1 is also included as part of the Java EE 6 platform.
  5. Run the Web service
    1. Right-click the project and select "Test RESTful Web Services":



      This deploys the created Web application on the selected GlassFish build and displays the following page in the default browser:


    2. Click on "deparmentss" and then on "Test" button to see the output as:



      Clicking the "Test" button issues a GET request to "http://localhost:8080/RestfulOracle/resources/departmentss". This uses the generated JAX-RS wrapper classes to talk to the database using JPA entity classes and query the first 10 rows from the "DEPARTMENTS" table. The response is then JSON formatted using JAX-RS wrapper classes and is returned to the requesting page which then displays it nicely formatted in the table. It also shows l-level deep department's relationship to other entities. If the "expandLevel" on the above page is set to "0", then the following output is shown:



      The "Raw View" (JSON data) of the original output looks like:



      Notice this is the raw JSON output generated by the JAX-RS wrapper classes. The "Http Monitor" traffic looks like:



      The format of data returned can be changed from "application/json" to "application/xml" as shown below:



      And even a POST request can be generated.

Do you have the need to expose your Oracle database tables as RESTful entities ?

A complete archive of all the TOTDs is available here.

This and other similar applications will be demonstrated at the upcoming Oracle Open World.

Technorati: totd oracle database glassfish v3 netbeans javaee jax-rs jpa rest

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

http://blogs.sun.com/arungupta/date/20091007 Wednesday October 07, 2009

TOTD #111: Rails Scaffold for a pre-existing table using Oracle and GlassFish

TOTD #110 explained how to create a brand new Rails application using Oracle database and run it using GlassFish v Gem. This Tip Of The Day explains how to create a scaffold for a sample schema that ships with Oracle database. Even though Rails Scaffold are good for, well, scaffolding but they do get you started easily. This blog will use the sample HR schema that comes along with Oracle database.

Lets get started!

  1. Copy the reverse_scaffold script in the "script" directory of your application created in TOTD #110. This script generates Model and Forms from a pre-existing database table. More details about this script are here.
  2. Edit "config/database.yml" and change the "development" section to:

    development:
    adapter: oracle_enhanced
    host: localhost
    database: orcl
    username: hr
    password: hr


    The changes are highlighted in bold, only the username and password values are changed to reflect the default values used with the sample database.
  3. Generate the models and forms for "departments" table as:
    ~/samples/v3/rails/oracle/bookstore >~/tools/jruby/bin/jruby script/reverse_scaffold departments department
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    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/departments
     exists app/views/layouts/
     exists test/functional/
     exists test/unit/
     create test/unit/helpers/
     exists public/stylesheets/
     create app/views/departments/index.html.erb
     create app/views/departments/show.html.erb
     create app/views/departments/new.html.erb
     create app/views/departments/edit.html.erb
     create app/views/layouts/departments.html.erb
     create public/stylesheets/scaffold.css
     create app/controllers/departments_controller.rb
     create test/functional/departments_controller_test.rb
     create app/helpers/departments_helper.rb
     create test/unit/helpers/departments_helper_test.rb
     route map.resources :departments
     dependency model
     exists app/models/
     exists test/unit/
     exists test/fixtures/
     create app/models/department.rb
     create test/unit/department_test.rb
     create test/fixtures/departments.yml
    
  4. Edit "app/models/department.rb" and specify the primary key to "department_id" column by adding:
    set_primary_key "department_id"
    

  5. Run the application as:
    ~/samples/v3/rails/oracle/bookstore >~/tools/jruby/bin/jruby -S glassfish -l
    Starting GlassFish server at: 129.145.133.197:3000 in development environment...
    Writing log messages to: /Users/arungupta/samples/v3/rails/oracle/bookstore/log/development.log.
    Press Ctrl+C to stop.
    Oct 6, 2009 2:14:19 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3000
    
    . . .
    

    The application is now accessible at "http://localhost:3000/departments" and looks like:
  6. Similarly, create the model and forms for "employees" table as:

    ~/samples/v3/rails/oracle/bookstore >~/tools/jruby/bin/jruby script/reverse_scaffold employees employee
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    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/employees
     exists app/views/layouts/
     exists test/functional/
     exists test/unit/
     exists test/unit/helpers/
     exists public/stylesheets/
     create app/views/employees/index.html.erb
     create app/views/employees/show.html.erb
     create app/views/employees/new.html.erb
     create app/views/employees/edit.html.erb
     create app/views/layouts/employees.html.erb
     identical public/stylesheets/scaffold.css
     create app/controllers/employees_controller.rb
     create test/functional/employees_controller_test.rb
     create app/helpers/employees_helper.rb
     create test/unit/helpers/employees_helper_test.rb
     route map.resources :employees
     dependency model
     exists app/models/
     exists test/unit/
     exists test/fixtures/
     create app/models/employee.rb
     create test/unit/employee_test.rb
     create test/fixtures/employees.yml
    

    Specify the primary key to "employee_id" by adding the following to "app/models/employee.rb" as:
    set_primary_key "employee_id"
    

    The scaffolded table is now available at "http://localhost:3000/employees" and looks like:

So we created a simple Rails CRUD application accessing information from a pre-existing table in the Oracle database server.

Thanks to @mediachk for all the help!

A complete archive of all the TOTDs is available here. The complete list of Rails blog entries are available here.

This and other similar applications will be demonstrated at the upcoming Oracle Open World.

Technorati: totd oracle database glassfish v3 jruby rails oow

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

http://blogs.sun.com/arungupta/date/20091006 Tuesday October 06, 2009

TOTD #110: JRuby on Rails application using Oracle on GlassFish

GlassFish v3 is the Reference Implementation for Java EE 6. Following the "extensibility" principle of Java EE 6, it also allows Ruby-on-Rails, Groovy and Grails and Python/Django applications to be seamlessly deployed as well, without any additional packaging. This blog has published multiple entries on deploying a Rails application on GlassFish as given below:

  • TOTD #105: Monitor Rails application using JavaScript
  • TOTD #104: Redmine, Typo, Substruct on GlassFish v3
  • TOTD #84: Apache + mod_proxy_balancer to load balance Rails applications on GlassFish
  • TOTD #81: nginx to load balance Rails applications on GlassFish Gem
  • TOTD #73: Deploying Rails application as WAR on GlassFish v2.1
  • TOTD #72: Deploying Rails application on GlassFish v3
  • TOTD #70: Deploying Rails application on GlassFish Gem

All the existing applications have used JavaDB, SQLite3, or MySQL as the database so far. In the process of getting ready for the upcoming Oracle Open World 2009, this Tip Of The Day will show how to use an Oracle database with a JRuby-on-Rails application deployed on GlassFish v3.

Lets get started!

  1. Install Oracle database as explained in TOTD #106.
  2. Configure JRuby/Rails in GlassFish v3 using one of the mechanisms explained in TOTD #104. Alternatively you can also install the GlassFish gem as:
    >./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 rack-1.0.0
    Successfully installed glassfish-0.9.5-universal-java
    2 gems installed
    Installing ri documentation for rack-1.0.0...
    Installing ri documentation for glassfish-0.9.5-universal-java...
    Installing RDoc documentation for rack-1.0.0...
    Installing RDoc documentation for glassfish-0.9.5-universal-java...
    

    This blog will use GlassFish Gem for running the application described below.
  3. Create a new database user and grant rights using SQL*Plus as shown:
    Macintosh-187:~ oracle$ sqlplus "/ as sysdba"
    SQL*Plus: Release 10.2.0.4.0 - Production on Thu Oct 1 12:32:33 2009
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    
    
    Connected to:
    Oracle Database 10g Release 10.2.0.4.0 - Production
    
    SQL> CREATE USER glassfish IDENTIFIED BY glassfish DEFAULT tablespace users TEMPORARY tablespace temp;
    
    User created.
    
    SQL> GRANT CONNECT TO glassfish IDENTIFIED BY glassfish;
    
    Grant succeeded.
    
    SQL> GRANT UNLIMITED TABLESPACE TO glassfish;
    
    Grant succeeded.
    
    SQL> GRANT CREATE TABLE TO glassfish;
    
    Grant succeeded.
    
    SQL> GRANT CREATE SEQUENCE TO glassfish;
    
    Grant succeeded.
    SQL> exit
    Disconnected from Oracle Database 10g Release 10.2.0.4.0 - Production
    
    
    The user name and password are chosen as "glassfish" for simplicity. This is not a recommended setting for production usage though.
  4. Copy Oracle JDBC drivers (odjc6.jar) in JRUBY_HOME/lib directory.
  5. Create a simple Rails application
    1. Make sure the following gems are pre-installed:
      rails (2.3.4)
      activerecord-jdbc-adapter (0.9.2)
      glassfish (0.9.5)
      

      If not, then install them as:
      jruby -S gem install rails activercord-jdbc-adapter glassfish
      
    2. Create a simple Rails application as:
      jruby -S rails bookstore -d oracle
      

    3. Using the normal "jdbc" adapter will give the following error later:

      ActionView::TemplateError (book_url failed to generate from {:controller=>"books", :action=>"show", :id=>#<Book id: #<BigDecimal:3feef1eb,'10000.0',1(8)>, title: "Ultramarathon Man", author: "Dean Karnazes", created_at: "2009-10-06 00:03:14", updated_at: "2009-10-06 00:03:14">}, expected: {:controller=>"books", :action=>"show"}, diff: {:id=>#<Book id: #<BigDecimal:459bdb65,'10000.0',1(8)>, title: "Ultramarathon Man", author: "Dean Karnazes", created_at: "2009-10-06 00:03:14", updated_at: "2009-10-06 00:03:14">}) on line #13 of app/views/books/index.html.erb:
      


      As evident, the "id" column is returned as BigDecimal where as it should be integer. Fortunately the fix is simple, install the "oracle_enhanced_adapter" (docs) as:

      bookstore >~/tools/jruby/bin/jruby -S gem install activerecord-oracle_enhanced-adapter
      JRuby limited openssl loaded. gem install jruby-openssl for full support.
      http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
      Successfully installed activerecord-oracle_enhanced-adapter-1.2.2
      1 gem installed
      Installing ri documentation for activerecord-oracle_enhanced-adapter-1.2.2...
      Installing RDoc documentation for activerecord-oracle_enhanced-adapter-1.2.2...
      

      Using this "enhanced adapter" is highly recommended for connecting with Oracle databases from Rails applications.
    4. Edit "config/database.yml" and change the "development" section to:
      development:
       adapter: oracle_enhanced
       host: localhost
       database: orcl
       username: glassfish
       password: glassfish
      

      Notice, the username and password values are the same as chosen in the SQL statements above.
    5. Generate a scaffold as:

      bookstore >~/tools/jruby/bin/jruby script/generate scaffold book title:string author:string
      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/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/20091005233152_create_books.rb
      
      
    6. Prepare your application for JDBC as:
      bookstore >~/tools/jruby/bin/jruby script/generate jdbc
      JRuby limited openssl loaded. gem install jruby-openssl for full support.
      http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
       exists config/initializers
       create config/initializers/jdbc.rb
       exists lib/tasks
       create lib/tasks/jdbc.rake
      

    7. Migrate the database as:
      ~/samples/v3/rails/oracle/bookstore >~/tools/jruby/bin/jruby -S rake db:migrate
      (in /Users/arungupta/samples/v3/rails/oracle/bookstore)
      == CreateBooks: migrating ====================================================
      -- create_table(:books)
       -> 0.0740s
       -> 0 rows
      == CreateBooks: migrated (0.0750s) ===========================================
      

  6. Lets run the application as:
    ~/samples/v3/rails/oracle/bookstore >~/tools/jruby/bin/jruby -S glassfish -l
    Starting GlassFish server at: 129.145.133.197:3000 in development environment...
    Writing log messages to: /Users/arungupta/samples/v3/rails/oracle/bookstore/log/development.log.
    Press Ctrl+C to stop.
    Oct 6, 2009 9:45:51 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
    INFO: Listening on port 3000
    
    . . .
    


    he application is now accessible at "http://localhost:3000/books" and looks like:



    Click on "New Book" and enter the values as shown:



    Click on "Create" to see the output as:



    Click on "Back" to see the main page as:



    After adding another book, this page looks like:



    And another book ...



So we created a brand new JRuby/Rails application and ran it using GlassFish and Oracle backend. A subsequent blog entry will show how to create a similar application using an existing database.

A complete archive of all the TOTDs is available here. The complete list of Rails blog entries are available here.

This and other similar applications will be demonstrated at the upcoming Oracle Open World.

Technorati: totd oracle database glassfish v3 jruby rails oow

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

http://blogs.sun.com/arungupta/date/20091004 Sunday October 04, 2009

Silicon Valley Code Code Camp 2009 Trip Report

The Foothill college was sprawling with developers, architects, engineers, et al from all over the San Francisco Bay Area to attend the Silicon Valley Code Camp 2009. This was my third speaking engagement (2008, 2007) and the code camp has certainly matured over the last years. The attendance is steadily growing and the quality of sessions is become more mature as well.

I presented on Java EE 6, GlassFish, and Eclipse Tooling for GlassFish/Java EE 6 and the slides are available below:

and

Both the talks were demo intensive and showed Deploy-on-Save, Preserving session state across deployments, Java EE 6 wizards in NetBeans (1, 2, 3, 4, 5) and Eclipse (1, 2, 3), Metro JAX-WS Web services development in Eclipse, GlassFish v3 Monitoring, GlassFish v3 REST interface to management and monitoring and many others. All the demos are available as screencasts and/or blog entries and the complete set of links are listed in the presentations.

Here are some pictures from the event:

And the complete album at:

That's it folks, see ya next year!

Technorati: siliconvalleycodecamp svcc glassfish javaee eclipse

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

http://blogs.sun.com/arungupta/date/20091002 Friday October 02, 2009

TOTD #109: How to convert a JSF managed bean to JSR 299 bean (Web Beans) ?

This entry is a follow up to TOTD #95 and shows how to use the recent integrations of JSR 299 in GlassFish v3 to convert a JSF managed bean to a JSR 299 bean (aka Web Beans). The TOTD #95 describes a simple Java EE 6 web application that uses Java Server Faces 2.0 components for displaying the results of a database query conducted by EJB 3.1 and JPA 2.0 classes.

The EJB class, which also acts as the JSF managed bean, looks like:

@javax.ejb.Stateless
@ManagedBean
public class StateList {
  @PersistenceUnit
  EntityManagerFactory emf;

  public List getStates() {
    return    emf.createEntityManager().createNamedQuery(”States.findAll”).getResultList();
  }
}

Three changes are required to convert this class into a JSR 299 compliant bean (Web Bean) as listed below:

  1. Add an empty "beans.xml" to the WEB-INF directory.
  2. Replace "@ManagedBean" with "@javax.inject.Named annotation". "@javax.inject" annotations are defined by JSR 330.
  3. Resource injection does not work with JPA classes, yet, so populate EntityManager explicitly as explained below:
    1. Replace EntityManagerFactory resource injection:

      @PersistenceUnit
      EntityManagerFactory emf;
      

      with:
      EntityManager emf = Persistence.createEntityManagerFactory("HelloEclipseLinkPU");
      
    2. Add the required entity classes explicitly to "persistence.xml". If the persistence unit is injected then the container automatically scans the web application root for any entity classes.
      1. Expand "Configuration Files" and edit "persistence.xml".
      2. Uncheck "Include All Entity Classes in ..." check box.
      3. Click on "Add Class...", select "state.States", and click on "OK".

That's it, re-deploy your application and now you are using the Web Beans integration in GlassFish v3 instead of JSF managed bean. The output is available at "http://localhost:8080/HelloEclipseLink/forwardToJSF.jsp" as shown:



This is the exact same output as shown in TOTD #95.

Now, one-by-one, JPA, EJB, Transactions and other components will start working. Read Roger's blog for another example of Web Beans in GlassFish.

A complete archive of all the tips is available here.

Technorati: totd glassfish v3 mysql javaee6 javaserverfaces webbeans jsr299 netbeans

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

http://blogs.sun.com/arungupta/date/20091001 Thursday October 01, 2009

TOTD #108: Java EE 6 web application (JSF 2.0 + JPA 2.0 + EJB 3.1) using Oracle, NetBeans, and GlassFish

TOTD #106 explained how to install Oracle database 10g R2 on Mac OS X. TOTD #107 explained how to connect this Oracle database using NetBeans. This Tip Of The Day will explain how to use the sample HR database (that comes with Oracle database server) to write a simple Java EE 6 application.

This application will use Java Server Faces 2.0 for displaying the results, Enterprise Java Beans 3.1 + Java Persistence API 2.0 for middle tier, and Oracle database server + GlassFish v3 as the backend. The latest promoted build (65 of this writing) will not work because of the issue #9885 so this blog will use build 63 instead.

Several improvements have been made over NetBeans 6.8 M1 build and this blog is using the nightly build of 9/27. The environment used in this blog is:

  • NetBeans 9/27 nightly
  • GlassFish v3 build 63
  • Oracle database server 10.2.0.4.0 R2 on Mac OS X
  • Oracle JDBC Driver type 4 (ojdbc6.jar)

Lets get started!

  1. Configure GlassFish v3 with JDBC connection
    1. Download and unzip build 63.
    2. Download ojdbc6.jar and copy to "glassfishv3/glassfish/domains/domain1/lib/ext" directory.
    3. Start the Application Server as:
      ./bin/asadmin start-domain --verbose &
      
    4. Create a JDBC connection pool as:
      ./bin/asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property "User=hr:Password=hr:URL=jdbc\:oracle\:thin\:@localhost\:1521\:orcl" jdbc/hr
      

      and verify the connection pool as:
      ./bin/asadmin ping-connection-pool jdbc/hr
      
    5. Create a JDBC resource as:
      ./bin/asadmin create-jdbc-resource --connectionpoolid jdbc/hr jdbc/hr
      
  2. Configure GlassFish v3 build 63 in NetBeans
    1. In NetBeans IDE "Services" panel, right-click on "Servers" and click on "Add Server...". Choose "GlassFish v3" and provide a name as shown below:


    2. Click on "Next >" and specify the unzipped GlassFish location as:



      and click on "Finish".
  3. Create the Java EE 6 application
    1. In "Projects" pane, right-click and select "New Project...".
    2. Choose "Java Web" and "Web Application" and click on "Next". Choose the project name as "HelloOracle":



      and click on "Next >".
    3. Select the recently added GlassFish v3 server and choose "Java EE 6 Web" profile:



      and click on "Next >". Notice "Java EE 6 Web" profile is chosen as the Java EE version.
    4. Select "JavaServer Faces" on the frameworks page:



      and click on "Finish". Notice the JSF libraries bundled with the App Server are used.
  4. Create the Java Persistence Unit
    1. Right-click on the project, select "New", "Entity Classes from Database...":


    2. From the Data Source, select "jdbc/hr" as shown:



      This is the same JDBC resource created earlier. Select "EMPLOYEES" from the Available Table, click on "Add >" to see the output as:



      The related tables are automatically included. Click on "Next >".
    3. Click on "Create Persistence Unit ..." and take all the defaults and click on "Create".
    4. Specify the package name as "model":



      and click on "Finish". This generates a JPA-compliant POJO class that provide access to tables in the underlying Oracle database. The class name corresponding to each table is shown in the wizard.
  5. Create Enterprise Java Beans
    1. Right-click on the project and select "New Class...".
    2. Specify the class name as "EmployeesBean" and package as "controller", click on "Finish".
    3. Annotate the class to make it an Enterprise Java Bean and a JSF Managed Bean as:
      @javax.ejb.Stateless
      @javax.faces.bean.ManagedBean
      


      Notice, the EJB is bundled in the WAR file and no special type of modules are required. Java EE 6 provides simplified packaging of EJB which makes it really ease to use.

      Also this application is currently using JSF managed bean but will use JSR 299 (aka Web Beans) in a future blog.
    4. Inject the Persistence Unit by adding the following variable:
      @PersistenceUnit
      EntityManagerFactory emf;
      
    5. Add a new method to retrieve the list of all employees as:
      public List getEmployees() {
       return em.createNamedQuery("Employees.findAll").getResultList();
      }
      

      "Employees.findAll" is a default NamedQuery generated by NetBeans and makes it easy to query the database. Several other queries are generated for each mapped JPA class, such as "Employees.findByEmployeeId" and "Employees.findByFirstName". Custom queries can also be created and specified on the POJO class.

      The completed class looks like:
      @Stateless
      @ManagedBean
      public class EmployeesBean {
      
       @PersistenceContext
       EntityManager em;
      
       public List getEmployees() {
       return em.createNamedQuery("Employees.findAll").getResultList();
       }
      }
      
  6. Use EJB in the generated JSF page
    1. JSF 2 uses Facelets as the templating mechanism and NetBeans generate a simple "index.xhtml" file to start with. Expand "Web Pages" and open "index.xhtml".
    2. Replace the body template with:
      <h1>First Java EE 6 app using Oracle database</>
      <h:dataTable var="emp" value="#{employeesBean.employees}" border="1">
       <h:column><h:outputText value="#{emp.lastName}"/>, <h:outputText value="#{emp.firstName}"/></h:column>
       <h:column><h:outputText value="#{emp.email}"/></h:column>
       <h:column><h:outputText value="#{emp.hireDate}"/></h:column>
       </h:dataTable>
      

      It uses JSF value expressions to bind the Enterprise Java Bean and dumps the HTML formatted name, email, and hire date of each employee in the database.
  7. Run the project: Right-click on the project and select "Run" to see the output at "http://localhost:8080/HelloOracle/" as:

So we can easily create a Java EE 6 application using NetBeans, Oracle, and GlassFish.

A complete archive of all the TOTDs is available here.

This and other similar applications will be demonstrated at the upcoming Oracle Open World.

Technorati: totd oracle database glassfish v3 javaee javaserverfaces ejb jpa netbeans oow

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

http://blogs.sun.com/arungupta/date/20090930 Wednesday September 30, 2009

TOTD #107: Connect to Oracle database using NetBeans

TOTD #106 explained how to install Oracle database 10g R2 on Mac OS X. This Tip Of The Day will explain how to connect Oracle database with NetBeans to leverage all the goodness provided by NetBeans for Java EE application development, Rails, and others.

  1. Download Oracle JDBC Drivers, specifically ojdbc14.jar. (ojdbc6.jar is recommended to be used with GlassFish v3).
  2. Using NetBeans 6.8 M1, in Services tab, right-click on "Databases" and select "New Connection..." as shown:


  3. Expand "Name:" and select "New Driver...":


  4. Click on "Add..." and choose the recently downloaded JDBC driver JAR file as shown below:



    and click on "OK".
  5. Enter the database values as shown below:



    The password is "hr" for the sample HR database. Clicking on "Show JDBC URL" also shows the complete JDBC URL. Click on "OK".

    You may have to unlock the "hr" user by giving the command:
    ALTER USER HR IDENTIFIED BY hr ACCOUNT UNLOCK;
    
    as explained in TOTD #106.
  6. Select the "HR" schema as shown below:



    and click on "OK". The complete list of schemas is now shown in the "Databases" node as shown below:

  7. Expand the "HR" node and the complete list of tables is visible now:



    Expanding each table shows you the complete definition as shown:

  8. Right-click on "COUNTRIES" table and select "View Data..."



    and the result is shown as:



    Additionally, you can execute any SQL command by selecting "Execute Command...":

A complete archive of all the TOTDs is available here.

Subsequent blogs will show how to write a Java EE application to access the Oracle database.

Technorati: totd oracle database netbeans

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

http://blogs.sun.com/arungupta/date/20090928 Monday September 28, 2009

TOTD #106: How to install Oracle Database 10g on Mac OS X (Intel) ?

This Tip Of The Day (TOTD) will explain how to install Oracle Database 10g on Mac OS X.

The official documentation is available here and is very well suited for folks with lots of time and patience. But all I wanted was to install Oracle database server up & running on my localhost so that I can start experimenting with it. All my previous entries have used either JavaDB or MySQL so far, but it's about time ;-)

I started preparing a brief tutorial after following the lengthy documentation but then found this excellent blog entry. And realized the content is looking exactly similar :-) Anyway, below are the instructions I followed and additionally also provide a snapshot of the installer windows.

For the brave of heart, complete installation guide is available in HTML and PDF. Read on for an abbreviated, and yet working version, of the instructions.

  1. Download Oracle database 10g R2 (10.2.0.4.0) from here and unzip.
  2. Check hardware/software requirements. (10.5.4+ required)
  3. Create required groups/users (complete details):
    1. Create Oracle inventory group as:

      # dscl . -create /groups/oinstall
      # dscl . -append /groups/oinstall gid 100
      # dscl . -append /groups/oinstall passwd "*"
      
    2. Create Oracle software owner as:
      # dscl . -create /users/oracle
      # dscl . -append /users/oracle uid uid_number
      # dscl . -append /users/oracle gid oinstall_gid
      # dscl . -append /users/oracle shell /bin/bash
      # dscl . -append /users/oracle home /Users/oracle
      # dscl . -append /users/oracle realname "Oracle software owner"
      
    3. Create the home directory for Oracle user as:
      # mkdir /Users/oracle
      # chown oracle:oinstall /Users/oracle
      
    4. Set the password for Oracle user:
      # passwd oracle
      
  4. Configure kernel parameters (complete details) by editing "/etc/sysctl.conf" and adding the contents:
    kern.sysv.semmsl=87381
    kern.sysv.semmns=87381
    kern.sysv.semmni=87381
    kern.sysv.semmnu=87381
    kern.sysv.semume=10
    kernel.shmall=2097152
    kernel.sys.shmmax=2147483648
    kernel.sys.shmmni=4096
    kern.maxfiles=65536
    kern.maxfilesperproc=65536
    net.inet.ip.portrange.first=1024
    net.inet.ip.portrange.last=65000
    kern.corefile=core
    kern.maxproc=2068
    kern.maxprocperuid=2068
    
    and reboot the machine for these parameters to take effect.
  5. Configure Oracle user's environment (complete details). In the "oracle" user's home directory, create ".bash_profile" and add the following lines:
    export DISPLAY=:0.0
    export ORACLE_BASE=$HOME
    export ORACLE_SID=orcl
    umask 022
    ulimit -Hn 65536
    ulimit -Sn 65536
    
  6. The "Basic Installation" of "Standard Edition" in an "Interactive" mode can be performed using the "Oracle Universal Installer". This installer is invoked using the script "db/Disk01/runInstaller" (complete details). The screen snapshots are shown below:

















    Choose "oracle" as the database password for simplicity.





    and finally click on "Install" to begin the installation.









    Click on "Password Management..." to unlock the sample database user ...





    The output of these scripts look like:
    ~ > sudo /Users/oracle/oraInventory/orainstRoot.sh
    Changing permissions of /Users/oracle/oraInventory to 770.
    Changing groupname of /Users/oracle/oraInventory to oinstall.
    The execution of the script is complete

    and
    ~ > sudo /Users/oracle/product/10.2.0/db_1/root.sh
    Running Oracle 10g root.sh script ...
    
    The following environment variables are set as:
         ORACLE_OWNER= oracle
         ORACLE_HOME= /Users/oracle/oracle/product/10.2.0/db_1
    Enter the full pathname of the local bin directory: [/usr/local/bin]:
        Copying dbhome /usr/local/bin ...
        Copying oraenv to /usr/local/bin ...
        Copying coraenv to /usr/local/bin ...
    Creating /etc/oratab file...
    Entries will be added to the /etc/oratab file as needed by
    Database Configuration Assistant when a database is created
    Finished running generic part of root.sh script.
    Now product-specific root actions will be performed.




    Click on "Installed Products..." to see the list of Oracle products installed.

  7. There are some more steps before you can start the Oracle listener process.
    1. Edit ".bash_profile" of "oracle" user and add the following settings:
      export ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
      export PATH=$PATH:$ORACLE_HOME/bin
      export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
      Not setting DYLD_LIBRARY_PATH gives the following error:
      ~ oracle$ lsnrctl start
      dyld: Library not loaded: /b/227/network/lib/libnnz10.dylib
        Referenced from: /Users/oracle/oracle/product/10.2.0/db_1/bin/lsnrctl
        Reason: image not found
      Trace/BPT trap
      This was not obvious but Googling helped. Make sure to relogin for these changes to take effect.
    2. If your Mac is using DHCP (most likely) then you may see the error shown below:
      ~ oracle$ lsnrctl start
      
      LSNRCTL for MacOS X Server: Version 10.2.0.4.0 - Production on 28-SEP-2009 14:48:49
      
      Copyright (c) 1991, 2007, Oracle.  All rights reserved.
      
      Starting /Users/oracle/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
      
      TNSLSNR for MacOS X Server: Version 10.2.0.4.0 - Production
      System parameter file is /Users/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
      Log messages written to /Users/oracle/oracle/product/10.2.0/db_1/network/log/listener.log
      Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
      Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dhcp-usca14-133-197.SFBay.Sun.COM)(PORT=1521)))
      TNS-12545: Connect failed because target host or object does not exist
       TNS-12560: TNS:protocol adapter error
        TNS-00515: Connect failed because target host or object does not exist
         MacOS X Server Error: 49: Can't assign requested address
      
      Listener failed to start. See the error message(s) above...


      This error occurs because your MacBook may be running on a different IP address if rebooted after the installation and before starting the server. Fortunately, the error message is very intuitive and it's easy to fix the error by editing "$ORACLE_HOME/network/admin/listener.ora" as shown below:
      # listener.ora Network Configuration File: /Users/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
      # Generated by Oracle configuration tools.
      
      SID_LIST_LISTENER =
        (SID_LIST =
          (SID_DESC =
            (SID_NAME = PLSExtProc)
            (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
            (PROGRAM = extproc)
          )
          (SID_DESC =
            (SID_NAME = orcl)
            (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
          )
        )
      
      LISTENER =
        (DESCRIPTION_LIST =
          (DESCRIPTION =
            (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
            (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
          )
        )
      

      The changes are highlighted in the bold. Basically, add a new SID referring to "orcl". And for DHCP users the value of HOST key needs to be changed from dynamically assigned IP address to "localhost". Strangely, the Installing on DHCP Computers section of the installation guide says nothing about it :(
    3. Additionally, for DHCP users, you need to change "$ORACLE_HOME/network/admin/tnsnames.ora" as:
      # tnsnames.ora Network Configuration File: /Users/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
      # Generated by Oracle configuration tools.
      
      ORCL =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
          (CONNECT_DATA =
            (SERVER = DEDICATED)
            (SERVICE_NAME = orcl)
          )
        )
      The changes are highlighted in bold. And here as well change the value of HOST key to "localhost".
  8. And finally, start the database using SQL*Plus as:
    ~ oracle$ sqlplus "/ as sysdba"
    
    SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 28 17:44:40 2009
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to an idle instance.
    
    SQL> startup nomount
    ORACLE instance started.
    
    Total System Global Area  612368384 bytes
    Fixed Size                  2085872 bytes
    Variable Size             167775248 bytes
    Database Buffers          436207616 bytes
    Redo Buffers                6299648 bytes
    SQL> alter database mount;
    
    Database altered.
    SQL> alter database open;
    Database altered.
    
    SQL> ALTER USER HR IDENTIFIED BY hr ACCOUNT UNLOCK;
    User altered.
    
    SQL> exit
    Disconnected from Oracle Database 10g Release 10.2.0.4.0 - Production
    The last step of unlocking the account should not be required because we explicitly unlocked the account during installation but that apparently didn't work. And I hit ORA-01033, ORA-01034, ORA-12514, ORA-12541, ORA-12547, and ORA-27101 trying different combinations to get the app working.

    Anyway now re-connect to the HR sample database as:
    
    ~ oracle$ sqlplus hr/hr@orcl
    
    SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 28 17:46:19 2009
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    
    Connected to:
    Oracle Database 10g Release 10.2.0.4.0 - Production
    
    SQL> select table_name from user_tables;
    TABLE_NAME
    ------------------------------
    REGIONS
    LOCATIONS
    DEPARTMENTS
    JOBS
    COUNTRIES
    EMPLOYEES
    JOB_HISTORY
    
    7 rows selected.
    
    SQL> desc regions;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     REGION_ID                                 NOT NULL NUMBER
     REGION_NAME                                        VARCHAR2(25)
    
    SQL> select * from regions;
     REGION_ID REGION_NAME
    ---------- -------------------------
             1 Europe
             2 Americas
             3 Asia
             4 Middle East and Africa
    

    Note: If the database is not shutdown properly then it can be forced to do so using the command "shutdown abort" using SQL*Plus.

A complete archive of all the tips is available here.


Technorati: totd oracle database mac osxtips leopard installation

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

http://blogs.sun.com/arungupta/date/20090924 Thursday September 24, 2009

Q&A Transcript from “Develop, Deploy, and Scale your Rails app with GlassFish” webinar

I delivered a "Develop, Deploy, and Scale your Rails app on GlassFish" webinar earlier today. There were over 300 unique attendees. A complete replay of the webinar is available at sun.com/software/webinars.

Many thanks to all the attendees for showing their interest in the technology and the panelists who relentlessly answered all the questions. The demos shown are available at:


An edited transcript of the Q&A session is available below. All the names have been removed for privacy reasons.


Q: I took leave from office to attend ur seession..:)
A: Thanks a lot, hopefully you'll enjoy it :)


Q: Is Rails an abbreviation?
A: http://rubyonrails.org/


Q: can you explain the difference b/t jruby and ruby
A: Ruby is a language and it's original interpreter is written in C. JRuby is pure Java based Ruby interpreter.


Q: What are the added benefits of installing JRuby on Glassfish - in compared to having it always in Rails app WAR?
A: What you get is the Ruby way of developing apps, code-save-refresh or agile experience


Q: Is it true on GF v2.1 as well - since the Rails app will anyway have to be packaged in a war?
A: On glassfish v2.x only WAR style Rails deployment is supported.


Q: Can I run existing rails application on GlassFish?
A: Yes. sure.


Q: is there support for rails 2.3.2? having trouble getting glassfish to run anything higher than 2.2.x
A: Yes, it is there.
A: Please send an email to dev@glassfish with your issue, we would be happy to help you


Q: what additional config is rerquired to support rails?
A: checkout http://wiki.glassfish.java.net/Wiki.jsp?page=GettingStartedGuide


Q: what I really was after is this: what is the difference of including JRuby (and dependent gems) inside your app war in compared to installing JRuby on GF and having only your own app in the war?
A: When you go in to production , you freeze your gems with app. The thing with glassfish v3 is that you can deploy rails app as WAR as well as directory deployment

Q: on jboss, i have to patch activerecord to use jndi style datasources. is that necessary on glassfish, too ?
A: No, you dont need to.


Q: do you have easy to follow lessons or tutorial for user to try a small real workable application to repeat what you are talking about from your website?
A: Check out checkout http://wiki.glassfish.java.net/Wiki.jsp?page=GettingStartedGuide


Q: y glass fish used only in java
A: GlassFish is a Java EE App Server


Q: Does Glassfish still have the PermGem out of memory issue when you deploy and undeploy applications.
A: There is a reasonable default setting for PermGen in Glassfish but it depends on your app. You can always set the PermGen to higher value
A: We have run significant number of tests to address this issue. If you do run into it, please let us know by sending an email to dev@glassfish


Q: what is mean by rails
A: http://rubyonrails.org/


Q: what is jruby?
A: Pure Java based Ruby interpreter. Checkout jruby.org


Q: what if i have glassfishv2 installed? is there any problem to install jruby gem glassfish?
A: GlassFish gem can be installed in an existing JRuby installation only. For GlassFish v2, Rails applications can only be deployed as WAR file.


Q: so the PermGen out of memory issue is supposedly fixed in Glassfish v3? Or should be fixed also in Glassfish v2.1?
A: when you start JVM there is PermGen space, scripting language interpreteres such as JRuby require higher perm gen. You just need to set it accordingly


Q: This may be a little off topic, but what are the Cons of using JRuby and glassfish? Because everything I've read is great
A: There might be some ruby gems that have native extensions that do not work on JRuby. Having said that, most of the ruby gems that we come across at work on JRuby just fine.


Q: on jboss, serveral jruby runtimes are added. same thing on glassfish ?
A: yes. you can configure the jruby runtime pool. See http://wiki.glassfish.java.net/Wiki.jsp?page=ConfiguringJRubyRuntimePool


Q: so why doesn't everyone use Jruyb? (over ruby MRI?)
A: Its a choice and really depends on personal preference. BTW as a datapoint, hosting company such as engineyard.com has jruby based Ruby/Rails hosting


Q: is this presentation only for mac users? I am a bit shocked with this OSX desktop. I was hoping seeing some Opensolaris etc.
A: No, it is not only for mac users


Q: does glassfish v3 already support cluster profiles?
A: glassfish v3 does not support clustering


Q: i always asked myself if the multiple jruby runtimes write to the same log file.
A: yes they do.


Q: so do you know when (in which release) will the clustering support be added to glassfish v3?
A: It is planned for glassfish v3.1.


Q: apart from glass fish any other server supports
A: mongrel, web rick work on jruby just fine.


Q: can we get support for jruby on jrails on glassfish?
A: Yes you can.
A: Sid, for details on GlassFish subscription support options, please email glassfish @sun.com


Q: yeah I saw that, a great option I think. I'm just at a state where I can pick either Ruby or JRuby, and JRuby seems far superior and can't really see any of it's fautls
A: yeah, pick JRuby!


Q: Does Ruby create for us the basic GUI for each table?
A: It's Rails that is creating the basic GUI for each table.


Q: why doesn't glassfish support clustering
A: GlassFish v2.1 supports clustering and can be run in production environment.


Q: apart from glass fish any other server supports j2ee
A: Which version of EE are you talking about?

Q: 1.6
A: 1.6 is not final yet, so glassfish is the only implementation of EE6 right now


Q: can you please email me the presentaion slides?
A: Please see www.sun.com/software/webinars - the slides maybe there.


Q: i heard that apache and tomcat server not used for j2ee? is it so?
A: Tomcat implements a subset of the Java EE specifications. It is not a fully compliant Java EE server. GlassFish is fully compliant (it's the reference implementation)


Q: We've been having some issues running Capistrano under JRuby on cygwin -- it gets confused about whether it's in a Windows or Unix-like environment. Any tips?
A: Could be cygwin issue? If not please report with details to users@glassfish.dev.java.net


Q: What is Rail Application
A: Check out http://rubyonrails.org for more details.


Q: sometimes, you might want to define a dedicated log file per deployed app. jboss logs everything to server.log by default. is it possible to define a dedicated log per app on glassfish
A: I dont have an answer to this, you may like to bring this question to users@glassfish.dev.java.net
A: I still dont see why this would an issue. As long as your logs shifts correctly and there is no locking etc. it should be fine. BTw, in production you limit your log anyway to severe error for perf reasons.


Q: so what're the benefits of using the glassfish gem versus mongrel or thin?
A: High performance, jruby runtime pool, daemon mode etc.


Q: Is the v3 Glassfish gem considered to be production ready?
A: Many users that I know already use in production.


Q: nginx or apache is recommended? can glassfish act as the comlete server?
A: GlassFish v3 does not support clustering. It will be coming up in a future release. So you may like to use squid or nginx etc to scale your app


Q: this update is shown how it is updated on mac OSX?
A: Update Center works on all platforms


Q: i'm new to glass fish beacuse i'm just a student....any websites or links that which makes 2 gain more knowledge on it.....
A: glassfish.dev.java.net can lead you to more details


Q: hey i missed the earlier part of this presentation..!
A: You can look at the recorded session later


Q: what is the built-in web server in glassfish used in the demo? wht would i use apache?
A: grizzly + v3 kernel+ jruby container. You can use Apache to front-end a bunch of GlassFish instances running at the backend.


Q: how to add extra gems in directrory-based deployment?
A: Just how you would use with any Rails app. gem install 'your gem'


Q: this is off the topic, is v3 glassfish going to implement directory based deployment for grails?
A: GlassFish embedded is in works and yes in will support grails directory deployment or 'grails run-app'


Q: Is there a major performance difference between the gem and the standalone war-style deployments?
A: Not much, With glassfish gem or glassfish v3 directory deployment, you are serving the requests at pretty low level. With war deployment its served by the web container

Q: in net beans only glassfish sever is implemented?if any other severs r there in net beans what are they.....
A: There are many other servers supported by NetBeans


Q: can i get the replay after the webinar?
A: Yes, the recorded session will be posted later at sun.com/software/webinars.


Q: in my company, we use a jboss / jruby / oracle setup. we have issues with newer version activerecord-jdbcadapter (> 8.1.0). is this a known problem ?
A: No idea, consider switching to GlassFish as it works fine there :)


Q: ok, so how does glassfish handle updating the source for your rails app? will it fulfill existing requests and smoothly 'seesaw' to updated instances? ...or does it just drop everything, redeploy and start over?
A: The experience is what you will get on native/MRI Ruby/Rails. glassfish embeds jruby using its internal API and rest is all Rails.

Q: so are gems pre packages apps to deploy?
A: think of gem like packages for Ruby/JRuby platforms.


Q: Please send me a link where I can retrieve the replay of this audio and presentation coz the buffering is really disturbed out here..
A: http://www.sun.com/software/webinars/ - recording of this session will be made available


Q: Regarding java gc/memory flags, is there a recommended set of flags for optimal glassfish performance
A: sun.com/glassfish/resources has a White Paper that shows how to tune GF. Although if you get the supported version, you get an add-on called Enterprise manager that can tune the server automatically.

Q: where will jruby be located when I install Jruby glassfish admin web page?
A: glassfish-install-dir/glassfish/jruby


Q: can I use Netbeans to set up my JRuby on Rails app and Glassfish server, but then use another editor or cmd prompt to edit/add to my app?
A: yes you can, although NetBeans provide a functionally complete IDE and serves all your needs.


Q: You are assuming that your server can access the internet. For example, to get the glassfish and Ruby and all upgrades and updates your update program gets the items from your server there on the internet. A secure vault does not have access to the intern
A: True. But you can prepackage everything.


Q: JAVA AND JAVAC NO WHERE IN PICTURE
A: GlassFish runs on java.


Q: is it possible to somehow change the rails.env setting _after_ a WAR has been generated? Or does it always require re-warblerizing?
A: warble config; edit config/warble.config to change. Otherwise export RAILS_ENV=production


Q: How would you debug if you packaged the Rails app as a warfile?
A: Thats an issue with the WAR based deployment. You should use directory deployment, specially for your development.


Q: all the server and application for jruby, integration also work on Windows XP professional?
A: Yes, it should work on Windows XP


Q: so jruby is really ready for primetime? good compatibility with existing gems and plugins?
A: yes it is.


Q: A different take on my blog post of the same topic http://javaevangelist.blogspot.com/2009/08/redmine-084-deployment-on-glassfish-21.html
A: thanks!


Q: Who is the best person to talk to about Grizzly failing to handle multi-part posts in a jruby rails app?
A: Please send email to dev@glassfish. Vivek Pandey is the lead for scripting in GlassFish


Q: are there any supports for pre-compiling ruby code to java byte code?
It would be great if I can hide my ruby code when I release my apps as war.
A: I know there is some jruby option that lets you do it. Either check on jruby.org or post it to users@jruby or #jruby on irc


Q: while we are using netbeans no problem because servers are inbuilt in the netbeans itself while we usin the ordinary notepad how the servers are to be implemented
A: I do not understand what you mean by implementing a server. A server implemention is implementing to the JavaEE spec. I assume you mean deploying on a server


Q: can anyother scripts can be used instead of javascript
A: Not yet. Ruby and groovy will be coming out in a future release


Q: is it possible to get access to the glassfish admin console using the gem?
A: Sorry, not yet.


Q: so NewRelic is jruby and glassfish compatible?
A: yep


Q: is there any way I can monitor server.log in glassfish admin web interface?
A: http://docs.sun.com/app/docs/doc/819-3656/6n5s3qjga?a=view - See bottom of URL.


Q: what is the preferred hardware for jruby and rails ? our experience is: sparc is slow and 86based sun hardware is fast for jruby
A: Not required but dual core or higher means better performance


Q: it is possible to implemet content management and ERP application with glassfish and has SUN such applications?
A: We know users deploying Ruby/Rails apps in OpenESB or in SOA env. For ERP or other content management system, as long as you can run these on Glassfish you can surely host Ruby aps there as well


Q: do you have the recommendation for jruby on rails book and good glassfish book?
A: There are several GlassFish books as listed at: http://blogs.sun.com/theaquarium/entry/more_glassfish_books. Practical JRuby on Rails is a nice book as well (http://www.rubyinside.com/practical-jruby-on-rails-book-by-ola-bini-625.html).


Q: Does Eclipse incorporate Ruby as NetNeans?
A: Both Eclipse and NetBeans are IDEs. Both support ruby development


Q: any other new servers r gonna compatible with glassfish
A: Once EE6 is final many other application servers will work towards being compatible with EE6


Q: what is the difference in case of performance between standlone war style deployement and gem deployement
A: Not much. gem will give you faster development cycle, easier deployment beside being very light weight (4MB) vs for WAR you need full server.


Q: is there any other IDE which supports ruby dev
A: Not integrated deployment and server side debugging. You can develop Ruby app on IDEA/Aptna studio etc. Typicaly you just need vi or text mate etc.


Q: why can't i run a project developed in netbeans 6.1 on netbeans 6.5
A: Please send an email to the netbeans forum


Q: can I deploy any ruby app I find on jruby?
A: JRuby 1.3.1 is 1.8.6 compliant and going to be using 1.8.7 as the baseline for upcoming JRuby 1.4. The JRuby team is also working on adding Ruby 1.9 compatibility.


Q: i've seen in netbeans at the end of netbeans it is end with IDE what is meant by IDE
A: IDE = "Integrated Development Environment"
A: There is a JRuby-specific distribution of NetBeans IDE


Q: why can't i run a project developed in netbeans 6.1 on netbeans 6.5?
A: You should be able to. If not, try posting to the Netbeans User's alias.


Q: We've been using JRuby on Windows, and are deploying to Solaris using Capistrano. We get mysterious problems establishing an ssh connection that we don't get when we use native Ruby. Any ideas on this?
A: Please send more details to dev@glassfish.dev.java.net
A: I guess I would need more details on this. you may like to post more info to users@jruby or #jruby irc
A: Paul: if you have purchased support - go through the support channel to address the issue quickly.


Q: Programming wise: are there any differences between ruby and jruby? b/c i think I'm now set on using glassfish, but I'd like to follow a lot of the tutorials out there, but almost all are for ruby
A: JRuby can run any Ruby application 1.8.7 and even 1.9


Q: are there any good books on the topic ?
A: There are several GlassFish books as listed at: http://blogs.sun.com/theaquarium/entry/more_glassfish_books. Practical JRuby on Rails is a nice book as well (http://www.rubyinside.com/practical-jruby-on-rails-book-by-ola-bini-625.html).


Q: the ide was complaining that some of the 'items' in the project are missing, how do i do it - netbeans 6.1 to 6.5
A: Sounds like a question that should be posted to the Netbeans email aliases. Sorry, the folks chatting away are GlassFish-centric.


Q: how i can more info about the EE6 and about the jruby
A: EE6 can be obtained from http://jcp.org/en/jsr/detail?id=313


Q: can JRuby run on Windows 7 and Windows Server 2008?
A: The only requirement for JRuby is JDK which is supported on those platforms, so yes JRuby should work there too.


Q: thanks! I was about to release my Jruby on rails glassfish in production. it encouraged me a lot!
A: Good to know, please send feedback to users@glassfish.dev.java.net.


Q: opensource+jruby+glassfish resources on the web?
A: jruby.org for JRuby, glassfish.org for GlassFish.


Q: so again there's full support for rails edge (2.3.2+) with the glassfish v2 server?
A: yes, you need to use warbler gem


Q: so since we already have a support contract with Sun we can also call you and ask about how to best deploy into production?
A: please email glassfish@sun.com and we will immediately reply with a call or answers to your questions.


Q: Is jruby compatible with all its older versions
A: They do maintain backwards compatibility. Ask this question at user@jruby.codehaus.org for a normative answer.


Q: does dun provide jruby training?
A: "Ruby, JRuby, and Rails development Development (with Passion!)" is a free course that offers that training. More details at: http://www.javapassion.com/rubyonrails/.


Q: can we deploy EAR on glassfish?????
A: Yes, GlassFish is a Java EE compliant app server so any standard EE artifact, such as EAR, can be easily deployed.


Q: would purchased support require us to deploy on v2?
A: No, you can choose the version of GlassFish you would like to deploy


Q: Can i build complex web system with glass fish, using such things as corba?
A: Very much, feel free to ask detailed question at users@glassfish.dev.java.net.


Q: I would like to know what would be best platform to use Glassfish on?
A: Being Sun, we prefer Solaris or OpenSolaris, but GlassFish also works well on Linux and Windows.


Q: how does jruby compare to ruby 1.9?
A: JRuby team is working on improving compatibility with Ruby 1.9. Ask your specific question to user@jruby.codehause.org.


Q: Great job guys! I am excited to use this.
A: Thanks, let us know your feedback on users@glassfish.dev.java.net.


Q: can glassfish be installed on amazon ec2?
A: Yes. There is an AMI with GlassFish, OpenSolaris, and MySQL
A: http://wikis.sun.com/display/sunsoftwareincloud/EC2+Glassfish


Q: is it very easy to deploy on glassfish
A: asadmin deploy yourrailsapp-dir/


Q: So what is the real advantage using ruby? Why not just use java script or some existing language, and what does the Rails part refer to?
A: Its Rails that makes it interesting. Rails is a complete MVC framework


Q: from where could i got jruby
A: JRuby can be downloaded form jruby.org.

Interested in watching a replay of the webinar ? Go to www.sun.com/offers/details/rails_apps.xml for all the details.

Technorati: glassfish rubyonrails jruby webinar netbeans

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

http://blogs.sun.com/arungupta/date/20090923 Wednesday September 23, 2009

TOTD #105: GlassFish v3 Monitoring – How to monitor a Rails app using asadmin, JavaScript, jConsole, REST ?

Monitoring infrastructure in GlassFish v3 is getting an extreme makeover. Prashanth defines it very nicely in his detailed introduction:

We provide a way to dynamically and non-intrusively generate monitoring events from any of the GlassFish runtime classes, the ability to listen to these events, collect the statistics and expose these statistics through various standard clients.

The "dynamic" nature indicates that monitoring can be turned ON or OFF in a GlassFish instance running in production environment. It also means the granularity to which the monitoring information can be generated. This information can be generated for not only a traditional Java EE applications, but Rails, Django and other type of applications that can be easily deployed on GlassFish v3. And that is extensible for other pluggable containers too. The data can be accessed using multiple mechanisms providing the administrator a wide variety of choice for tools, e.g. DTrace, JMX, REST, asadmin CLI, and Admin Console and thus another point in favor of "dynamic".

The "non-intrusive" behavior means that monitoring can be used in production environment with minimal overhead. It also means that there is no overhead when monitoring is not enabled. Anyway, monitoring needs to be explicitly enabled as explained below.

As mentioned above, there are multiple ways to access the monitoring data. The different ways to access the monitoring data are:

  1. DTrace scripts (only on Solaris)
  2. asadmin CLI
  3. Admin Console
  4. JMX/jConsole
  5. REST
  6. Custom client using a 3rd party scripting language (available as value-add feature to paid customers only)

This Tip Of The Day will describe how to access the monitoring data using asadmin CLI and a JavaScript client. Note that the JavaScript client feature is available as a value-add to the community version of GlassFish and available only to the paid customers.

This tip will use a pre-deployed Rails application as (Redmine as described in TOTD #104) on a nightly GlassFish v3 build (CI, nightly, or promoted) and explains how to monitor this application.

Using the terminology defined in Monitoring in GlassFish v3 blog, the JRuby subsystem in GlassFish has multiple probe providers and each provider has multiple probes. The JRuby subsystem also provides multiple stats providers with probe listeners. All of these elements are linked using the monitoring infrastructure in GlassFish.

Lets monitor our Rails application

Monitoring using asadmin CLI

By default the monitoring is turned OFF for all the components. Lets enable monitoring for the JRuby container as:

asadmin enable-monitoring --level jruby-container=HIGH

The other possible values are "LOW" and "OFF". All the probes publishing monitoring data can be listed as:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin list --monitor=true "*"
server
server.containers
server.containers.jruby
server.containers.jruby.applications
server.containers.jruby.http
server.containers.jruby.http.redmine-0.8.5
server.containers.jruby.runtime-pool
server.containers.jruby.runtime-pool.redmine-0.8.5

Command list executed successfully.

A snapshot of the monitoring data can be obtained as:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin get --monitor=true "*jruby*"
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-appName = redmine-0.8.5
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-description =
 server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-environment = development
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-jrubyVersion = 1.3.0
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-lastsampletime = 1253322280437
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-name = redmine-0.8.5
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-rubyFramework = rails
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-starttime = 1253322280437
server.containers.jruby.applications.activerubyapplications.redmine-0.8.5-unit =
server.containers.jruby.applications.activerubyappscount-count = 1
server.containers.jruby.applications.activerubyappscount-description = Number of currently loaded Ruby applications
server.containers.jruby.applications.activerubyappscount-lastsampletime = 1253322279921
server.containers.jruby.applications.activerubyappscount-name = ActiveRubyApplications
server.containers.jruby.applications.activerubyappscount-starttime = 1253322279922
server.containers.jruby.applications.activerubyappscount-unit = count
server.containers.jruby.http.redmine-0.8.5.address = null
server.containers.jruby.http.redmine-0.8.5.averageprocessingtime = 0
server.containers.jruby.http.redmine-0.8.5.count200-count = 0
server.containers.jruby.http.redmine-0.8.5.count200-description = Number of responses with a status code equal to 200
server.containers.jruby.http.redmine-0.8.5.count200-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count200-name = Count200
server.containers.jruby.http.redmine-0.8.5.count200-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count200-unit = count
server.containers.jruby.http.redmine-0.8.5.count2xx-count = 0
server.containers.jruby.http.redmine-0.8.5.count2xx-description = Number of responses with a status code in the 2xx range
server.containers.jruby.http.redmine-0.8.5.count2xx-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count2xx-name = Count2xx
server.containers.jruby.http.redmine-0.8.5.count2xx-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count2xx-unit = count
server.containers.jruby.http.redmine-0.8.5.count302-count = 0
server.containers.jruby.http.redmine-0.8.5.count302-description = Number of responses with a status code equal to 302
server.containers.jruby.http.redmine-0.8.5.count302-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count302-name = Count302
server.containers.jruby.http.redmine-0.8.5.count302-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count302-unit = count
server.containers.jruby.http.redmine-0.8.5.count304-count = 0
server.containers.jruby.http.redmine-0.8.5.count304-description = Number of responses with a status code equal to 304
server.containers.jruby.http.redmine-0.8.5.count304-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count304-name = Count304
server.containers.jruby.http.redmine-0.8.5.count304-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count304-unit = count
server.containers.jruby.http.redmine-0.8.5.count3xx-count = 0
server.containers.jruby.http.redmine-0.8.5.count3xx-description = Number of responses with a status code in the 3xx range
server.containers.jruby.http.redmine-0.8.5.count3xx-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count3xx-name = Count3xx
server.containers.jruby.http.redmine-0.8.5.count3xx-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count3xx-unit = count
server.containers.jruby.http.redmine-0.8.5.count400-count = 0
server.containers.jruby.http.redmine-0.8.5.count400-description = Number of responses with a status code equal to 400
server.containers.jruby.http.redmine-0.8.5.count400-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count400-name = Count400
server.containers.jruby.http.redmine-0.8.5.count400-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count400-unit = count
server.containers.jruby.http.redmine-0.8.5.count401-count = 0
server.containers.jruby.http.redmine-0.8.5.count401-description = Number of responses with a status code equal to 401
server.containers.jruby.http.redmine-0.8.5.count401-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count401-name = Count401
server.containers.jruby.http.redmine-0.8.5.count401-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count401-unit = count
server.containers.jruby.http.redmine-0.8.5.count403-count = 0
server.containers.jruby.http.redmine-0.8.5.count403-description = Number of responses with a status code equal to 403
server.containers.jruby.http.redmine-0.8.5.count403-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count403-name = Count403
server.containers.jruby.http.redmine-0.8.5.count403-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count403-unit = count
server.containers.jruby.http.redmine-0.8.5.count404-count = 0
server.containers.jruby.http.redmine-0.8.5.count404-description = Number of responses with a status code equal to 404
server.containers.jruby.http.redmine-0.8.5.count404-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count404-name = Count404
server.containers.jruby.http.redmine-0.8.5.count404-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count404-unit = count
server.containers.jruby.http.redmine-0.8.5.count4xx-count = 0
server.containers.jruby.http.redmine-0.8.5.count4xx-description = Number of responses with a status code in the 4xx range
server.containers.jruby.http.redmine-0.8.5.count4xx-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count4xx-name = Count4xx
server.containers.jruby.http.redmine-0.8.5.count4xx-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count4xx-unit = count
server.containers.jruby.http.redmine-0.8.5.count503-count = 0
server.containers.jruby.http.redmine-0.8.5.count503-description = Number of responses with a status code equal to 503
server.containers.jruby.http.redmine-0.8.5.count503-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count503-name = Count503
server.containers.jruby.http.redmine-0.8.5.count503-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count503-unit = count
server.containers.jruby.http.redmine-0.8.5.count5xx-count = 0
server.containers.jruby.http.redmine-0.8.5.count5xx-description = Number of responses with a status code in the 5xx range
server.containers.jruby.http.redmine-0.8.5.count5xx-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count5xx-name = Count5xx
server.containers.jruby.http.redmine-0.8.5.count5xx-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.count5xx-unit = count
server.containers.jruby.http.redmine-0.8.5.countother-count = 0
server.containers.jruby.http.redmine-0.8.5.countother-description = Number of responses with other status codes
server.containers.jruby.http.redmine-0.8.5.countother-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.countother-name = CountOther
server.containers.jruby.http.redmine-0.8.5.countother-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.countother-unit = count
server.containers.jruby.http.redmine-0.8.5.errorcount-count = 0
server.containers.jruby.http.redmine-0.8.5.errorcount-description = Number of responses with a status code greater than 400
server.containers.jruby.http.redmine-0.8.5.errorcount-lastsampletime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.errorcount-name = ErrorCount
server.containers.jruby.http.redmine-0.8.5.errorcount-starttime = 1253322280245
server.containers.jruby.http.redmine-0.8.5.errorcount-unit = count
server.containers.jruby.http.redmine-0.8.5.requestcount-count = 0
server.containers.jruby.http.redmine-0.8.5.requestcount-description = Number of HTTP requests received
server.containers.jruby.http.redmine-0.8.5.requestcount-lastsampletime = 1253322280243
server.containers.jruby.http.redmine-0.8.5.requestcount-name = RequestCounter
server.containers.jruby.http.redmine-0.8.5.requestcount-starttime = 1253322280243
server.containers.jruby.http.redmine-0.8.5.requestcount-unit = count
server.containers.jruby.http.redmine-0.8.5.requestpersecond = null
server.containers.jruby.runtime-pool.redmine-0.8.5.activeruntimes-count = 1
server.containers.jruby.runtime-pool.redmine-0.8.5.activeruntimes-description = Currently active runtimes
server.containers.jruby.runtime-pool.redmine-0.8.5.activeruntimes-lastsampletime = 1253322280241
server.containers.jruby.runtime-pool.redmine-0.8.5.activeruntimes-name = activeRuntimes
server.containers.jruby.runtime-pool.redmine-0.8.5.activeruntimes-starttime = 1253322280241
server.containers.jruby.runtime-pool.redmine-0.8.5.activeruntimes-unit = count
server.containers.jruby.runtime-pool.redmine-0.8.5.applicationname = redmine-0.8.5
server.containers.jruby.runtime-pool.redmine-0.8.5.contextpath = /redmine-0.8.5
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmaximum-count = 1
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmaximum-description = Maximum active runtimes
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmaximum-lastsampletime = 1253322280241
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmaximum-name = hardMaximum
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmaximum-starttime = 1253322280241
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmaximum-unit = count
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmminimum-count = 1
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmminimum-description = Minimum active runtimes
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmminimum-lastsampletime = 1253322280241
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmminimum-name = hardMinimum
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmminimum-starttime = 1253322280241
server.containers.jruby.runtime-pool.redmine-0.8.5.hardmminimum-unit = count

Command get executed successfully.

The command asadmin get --monitor=true "*jruby*" dumps a snapshot of the monitoring data such as the number of Ruby currently applications loaded, application name, JRuby version, environment (development / test / production), currently active runtimes, min/max runtimes, number of HTTP requests / responses with a certain HTTP code and much more information. It basically dumps all the JRuby monitoring information captured so far.

An alternate regular expression may be specified such as:

asadmin get --monitor=true "*jruby*runtime-pool*"

to gather only the runtime pool specific values.

Monitoring using JavaScript client

Third-party scripting client are a value-add to the community versions. Just like Enterprise Manager, the value-add will be available as a patch to the users who purchase commercial support. Lets see what can be done with it though.

First of all you can type the command "list-probes" to see a list of all the probes that are available. A typical output will look like:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin list-probes
glassfish:kernel:connections-keep-alive:decrementCountConnectionsEvent decrementCountConnectionsEvent(java.lang.String)
glassfish:web:web-module:webModuleStoppedEvent webModuleStoppedEvent(java.lang.String, java.lang.String)
glassfish:jca:connection-pool:connectionValidationFailedEvent connectionValidationFailedEvent(java.lang.String, int)
glassfish:jca:work-management:workWaitedFor workWaitedFor(java.lang.String, long)
glassfish:jdbc:connection-pool:connectionTimedOutEvent connectionTimedOutEvent(java.lang.String)
glassfish:security:ejbpolicy:ejbPCCreationEvent ejbPCCreationEvent(java.lang.String)
glassfish:kernel:thread-pool:threadReturnedToPoolEvent threadReturnedToPoolEvent(java.lang.String, java.lang.String)
glassfish:web:session:sessionPersistedEndEvent sessionPersistedEndEvent(java.lang.String, java.lang.String, java.lang.String)
glassfish:web:http-service:requestStartEvent requestStartEvent(java.lang.String, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)
glassfish:jdbc:connection-pool:connectionsFreedEvent connectionsFreedEvent(java.lang.String, int)
glassfish:jdbc:connection-pool:toString toString(java.lang.String, java.lang.StringBuffer)
glassfish:jca:connection-pool:decrementFreeConnectionsSizeEvent decrementFreeConnectionsSizeEvent(java.lang.String, int)
glassfish:kernel:connections-keep-alive:incrementCountFlushesEvent incrementCountFlushesEvent(java.lang.String)
glassfish:webservices:109:deploy deploy(com.sun.enterprise.deployment.Application, com.sun.enterprise.deployment.WebServiceEndpoint)
glassfish:jca:connection-pool:connectionAcquiredEvent connectionAcquiredEvent(java.lang.String)
glassfish:web:http-service:requestEndEvent requestEndEvent(java.lang.String, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, int)
glassfish:kernel:connections-keep-alive:incrementCountRefusalsEvent incrementCountRefusalsEvent(java.lang.String)
glassfish:kernel:connections:connectionConnectedEvent connectionConnectedEvent(java.lang.String, int)
glassfish:kernel:file-cache:addHeapSizeEvent addHeapSizeEvent(java.lang.String, long)
glassfish:jruby:runtime-pool:runtimePoolUpdateEvent runtimePoolUpdateEvent(java.lang.String, int, int, int, int, int)
glassfish:security:web:securityManagerCreationEvent securityManagerCreationEvent(java.lang.String)
glassfish:security:web:securityManagerDestructionEvent securityManagerDestructionEvent(java.lang.String)
glassfish:webservices:ri:undeploy undeploy(com.sun.xml.ws.transport.http.servlet.ServletAdapter)
glassfish:web:session:sessionPersistedStartEvent sessionPersistedStartEvent(java.lang.String, java.lang.String, java.lang.String)
glassfish:ejb:pool:objectAddedEvent ejbObjectAddedEvent()
glassfish:ejb:bean:methodStartEvent ejbMethodStartEvent(java.lang.String, java.lang.String, java.lang.String, java.lang.reflect.Method)
glassfish:jdbc:connection-pool:connectionRequestServedEvent connectionRequestServedEvent(java.lang.String, long)

All the JRuby probes can be easily listed as:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin list-probes | grep jruby
glassfish:jruby:runtime-pool:runtimePoolUpdateEvent runtimePoolUpdateEvent(java.lang.String, int, int, int, int, int)
glassfish:jruby:http:requestStartEvent requestStartEvent(java.lang.String, java.lang.String, int)
glassfish:jruby:jruby-container:jrubyModuleStartedEvent jrubyModuleStartedEvent(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
glassfish:jruby:jruby-container:jrubyModuleStoppedEvent jrubyModuleStoppedEvent(java.lang.String, java.lang.String, java.lang.String)
glassfish:jruby:http:requestEndEvent requestEndEvent(java.lang.String, int)
glassfish:jruby:runtime-pool:runtimePoolStartEvent runtimePoolStartEvent(java.lang.String, int, int, int, int, int, int, int)

More detailed information about each probe can be easily found by giving the command:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin list-probes --manpage=true glassfish:jruby:runtime-pool:runtimePoolUpdateEvent

This will show the detailed information ("man" pages) about the specific probe. A JavaScript client to monitor the deployed Rails application and gather the relevant statistics can be written using these pages as shown below:

moduleStarted = function(appName, appType, env, jruby) {
    client.print( '\n log> Deployed a \'' + appType + '\' app named \'' + appName + '\' in \'' + env + '\' environment with JRuby \'' + jruby + '\'.');
}

moduleStopped = function(appName, appType, env) {
    client.print( '\n log> Undeployed a \'' + appType + '\' app named \'' + appName + '\' in \'' + env + '\' environment.');
}

requestStarted = function(contextPath, serverName, port) {
    client.print( '\n log> Request started at \'' + contextPath + '\' hosted on \'' + serverName + ':' + port + '\'');
}

requestEnded = function(contextPath, statusCode) {
    client.print( '\n log> Request stopped at \'' + contextPath + '\' with status code \'' + statusCode + '\'');
}

runtimePoolStart = function(appName, activeRuntimes, queueSize) {
   client.print( '\n log> JRuby runtime pool started for the app \'' + appName + '\': active runtime - ' + activeRuntimes + ', queue size - ' + queueSize);
}

runtimePoolUpdate = function(appName, activeRuntimes, queueSize) {
   client.print( '\n log> JRuby runtime pool updated for the app \'' + appName + '\': active runtime - ' + activeRuntimes + ', queue size - ' + queueSize);
}

moduleStartedParams = java.lang.reflect.Array.newInstance(java.lang.String, 4);
moduleStartedParams[0]="appName";
moduleStartedParams[1]="applicationType";
moduleStartedParams[2]="environment";
moduleStartedParams[3]="jrubyVersion";
scriptContainer.registerListener('glassfish:jruby:jruby-container:jrubyModuleStartedEvent', moduleStartedParams, 'moduleStarted');

moduleStoppedParams = java.lang.reflect.Array.newInstance(java.lang.String, 3);
moduleStoppedParams[0]="appName";
moduleStoppedParams[1]="applicationType";
moduleStoppedParams[2]="environment";
scriptContainer.registerListener('glassfish:jruby:jruby-container:jrubyModuleStoppedEvent', moduleStoppedParams, 'moduleStopped');

requestStartParams = java.lang.reflect.Array.newInstance(java.lang.String, 3);
requestStartParams[0]="contextPath";
requestStartParams[1]="serverName";
requestStartParams[2]="port";
scriptContainer.registerListener('glassfish:jruby:http:requestStartEvent', requestStartParams, 'requestStarted');

requestEndParams = java.lang.reflect.Array.newInstance(java.lang.String, 2);
requestEndParams[0]="contextPath";
requestEndParams[1]="statusCode";
scriptContainer.registerListener('glassfish:jruby:http:requestEndEvent', requestEndParams, 'requestEnded');

runtimePoolParams = java.lang.reflect.Array.newInstance(java.lang.String, 3);
runtimePoolParams[0]="appName";
runtimePoolParams[1]="activeRuntimes";
runtimePoolParams[2]="queueSize";
scriptContainer.registerListener('glassfish:jruby:runtime-pool:runtimePoolStartEvent', runtimePoolParams, 'runtimePoolStart');
scriptContainer.registerListener('glassfish:jruby:runtime-pool:runtimePoolUpdateEvent', runtimePoolParams, 'runtimePoolUpdate');

This script register listeners for different probe events, pass a set of parameters that need to be captured, and print the information in a callback method specified during registration. The number of listeners and parameters / listener may be altered to meet your data capturing needs.

This script is stored in a file "monitor-rails.js" and used as described below. As a Rails application is deployed, requests invoked, and undeployed, the following messages are printed on the console:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin run-script monitor-rails.js


 log> Deployed a 'rails' app named 'redmine-0.8.5' in 'development' environment with JRuby '1.3.0'.
 log> JRuby runtime pool started for the app 'redmine-0.8.5': active runtime - 1, queue size - 0
 log> Request started at '/redmine-0.8.5' hosted on 'localhost:8080'
 log> Request stopped at '/redmine-0.8.5' with status code '200'
 log> Request started at '/redmine-0.8.5' hosted on 'localhost:8080'
 log> Request stopped at '/redmine-0.8.5' with status code '200'
 log> Undeployed a 'rails' app named 'redmine-0.8.5' in 'development' environment.

Note "run-script" is the command that comes as part of the value-add. As described earlier, a snapshot of the monitoring information can be easily captured using asadmin as:

~/tools/glassfish/v3/9-18/glassfishv3 >./bin/asadmin get --monitor=true "*jruby*request*"
server.containers.jruby.http.redmine-0.8.5.requestcount-count = 2
server.containers.jruby.http.redmine-0.8.5.requestcount-description = Number of HTTP requests received
server.containers.jruby.http.redmine-0.8.5.requestcount-lastsampletime = 1253638362651
server.containers.jruby.http.redmine-0.8.5.requestcount-name = RequestCounter
server.containers.jruby.http.redmine-0.8.5.requestcount-starttime = 1253638362651
server.containers.jruby.http.redmine-0.8.5.requestcount-unit = count
server.containers.jruby.http.redmine-0.8.5.requestpersecond = 1

Command get executed successfully.

As you can see, the total number of requests is shown as "2".

Just for fun, I ran Apache ab with 20 requests and 4 concurrency ("-n 20 -c 4") on "http://localhost:8080/redmine-0.8.5" and saw the following results:

Monitoring OFF
(default)
Monitoring=HIGH
(no data printed)
Monitoring=HIGH
(data printed)
Time taken for requests (secs) 26.231 26.997 26.665
Requests per second 0.76 0.74 0.75
Time per request (ms) 1311.574 1349.859 1333.239


The server was restarted between each run. These numbers were generated on my development machine so they are most likely skewed. But as a development benchmark the numbers do indicate that GlassFish v3 monitoring is truly non-intrusive. The total time taken for requests, requests/second, and time/request is pretty much identical.

Future blogs will cover how to access this data using web-based DTrace scripts, web-based Admin Console, jConsole, and REST interface.

A complete archive of all the tips is available here.

Technorati: totd glassfish v3 monitoring asadmin javascript jruby rails redmine

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

Valid HTML! Valid CSS!

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