Twitter Updates

Archive for September, 2008

Muslim Children Gassed at Dayton Mosque After “Obsession” DVD Hits Ohio

Sunday, September 28th, 2008

Muslim Children Gassed at Dayton Mosque After “Obsession” DVD Hits Ohio

  • “She told me that the gas was sprayed into the room where the babies and children were being kept while their mothers prayed together their Ramadan prayers. Panicked mothers ran for their babies, crying for their children so they could flee from the gas that was burning their eyes and throats and lungs. She grabbed her youngest in her arms and grabbed the hand of her other daughter, moving with the others to exit the building and the irritating substance there.
  • “The paramedic said the young one was in shock, and gave her oxygen to help her breathe. The child couldn’t stop sobbing.
  • “This didn’t happen in some far away place — but right here in Dayton, and to my friends. Many of the Iraqi refugees were praying together at the Mosque Friday evening. People that I know and love.
  • “I am hurt and angry. I tell her this is NOT America. She tells me this is not Heaven or Hell — there are good and bad people everywhere.
  • “She tells me that her daughters slept with her last night, the little one in her arms and sobbing throughout the night. She tells me she is afraid, and will never return to the mosque, and I wonder what kind of country is this where people have to fear attending their place of worship?
  • “The children come into the room, and tell me they want to leave America and return to Syria, where they had fled to from Iraq. They say they like me, … , and other American friends — but they are too afraid and want to leave. Should a 6 and 7 year old even have to contemplate the safety of their living situation?
  • “Did the anti-Muslim video circulating in the area have something to do with this incident, or is that just a bizarre coincidence? Who attacks women and children?
  • “What am I supposed to say to them? My words can’t keep them safe from what is nothing less than terrorism, American style. Isn’t losing loved ones, their homes, jobs, possessions and homeland enough? Is there no place where they can be safe?
  • “She didn’t want me to leave her tonight, but it was after midnight, and I needed to get home and write this to my friends. Tell me — tell me — what am I supposed to say to them?”

Setting up JRuby on Rails

Tuesday, September 9th, 2008

In my last blog, I wrote about recent JRuby on Rails project I did at amazon. In this blog, I will show some technical details on setting up JRuby on Rails with Tomcat. I used 2.1.1 of Rails and 1.1.4 of JRuby, here are steps to setup JRuby and Rails:

  • Download Jruby 1.1.4 from http://dist.codehaus.org/jruby/
  • Setup JRUBY_HOME and PATH
     export JRUBY_HOME=installed directory of jruby
     export PATH=$JRUBY_HOME/bin:$PATH
     
  • Install Rails
     gem install rails -y
     
  • Install ActiveRecord JDBC Adapter
     jruby -S gem install activerecord-jdbc-adapter
     
  • Install warbler plugin to create war file, older version of Rails (1.2 or older) used goldspike but the newer version requires warbler
     jruby -S gem install -y  warbler
     
  • Edit config/environment.rb and add
     if RUBY_PLATFORM =~ /java/
       require 'rubygems'
       RAILS_CONNECTION_ADAPTERS = %w(jdbc)
     end
     
  • Download mysql-jdbc driver as I used MySQL. (You may have to download different driver. )
  • Copy mysql-connector-java-5.1.6-bin.jar to lib directory of jruby
  • You can edit config/warble.rb and add other jar files or directories, e.g.
       config.java_libs += FileList["lib/*.jar"]
       config.pathmaps.java_classes << "%{build/classes/,}p"
       config.webxml.jruby.min.runtimes = 2
       config.webxml.jruby.max.runtimes = 24
     
  • Edit config/environment.rb and add define adapter, driver and url as follows:
     development:
       adapter: jdbc
       driver: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost/rspm_development
       username: rspmdb_user
       password: secret
    
     test:
       adapter: jdbc
       driver: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost/rspm_test
       username: rspmdb_user
       password: secret
    
     production:
       adapter: jdbc
       driver: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost/rspm_production
       username: rspmdb_user
       password: secret
     
  • Create a template web.xml.erb in config directory, e.g.
     <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    
       "http://java.sun.com/dtd/web-app_2_3.dtd">
     <web-app>
    
         <% webxml.context_params.each do |k,v| %>
         <context-param>
             <param-name><%= k %></param-name>
             <param-value><%= v %></param-value>
    
         </context-param>
         <% end %>
    
        <servlet>
           <servlet-name>Rails</servlet-name>
           <servlet-class>org.jruby.rack.RackServlet</servlet-class>
    
        </servlet>
    
        <servlet-mapping>
            <servlet-name>Rails</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    
       <filter>
         <filter-name>RackFilter</filter-name>
         <filter-class>org.jruby.rack.RackFilter</filter-class>
       </filter>
    
       <filter-mapping>
         <filter-name>RackFilter</filter-name>
         <url-pattern>/*</url-pattern>
       </filter-mapping>
    
        <listener>
    
           <listener-class><%= webxml.servlet_context_listener || 'org.jruby.rack.RackServletContextListener'%></listener-class>
        </listener>
    
     </web-app>
    
  • Now create war file
     jruby -S warble
     
  • Finally copy the war file to webapps directory of standard J2EE web container, in my case Tomcat 6.0
  • Now point the browser to your server, e.g. http://localhost:8080/your-controller and voilla.

On final note, I found warble quite slow in generating war file and tomcat takes a while to deploy the war file, so I use WEBrick for development and Tomcat for staging/production.

Rails save the day

Saturday, September 6th, 2008

In our daily scrum meeting at work last week, we identified one of application that had been crashing often. The application was pretty simple web application written in Java using Spring-MVC, Hibernate, Spring and Apache-commons libraries. However, the developer who released it embedded that application in another much bigger web application in order to save some deployment issues, which can be real pain at amazon. So, I volunteered to address the issue and rewrite the application in JRuby on Rails (2.1). It took me a day to rewrite all application and migrate all data from the old application. Along the way, I also added a couple of some additional features. The original application took a couple of weeks to develop and was consisted of over 6500 lines of code. The ruby version consisted a little less than 800 lines of code. I have been using Ruby on my own since 2004 and started learning Rails in 2005. Though, I started using Rails a bit more on some side projects after I attended Rails conference of 2006. I still use Java for most of the work, and was delighted to show speed of development with Rails at work. Since, the deployment issues are still pain in Rails so I chose JRuby that allows Rails apps to deploy on Tomcat, which we are using for most of the projects. Hopefuly, that will fix the stability issues and save me from pagers as I will be oncall next week.