Wednesday, December 3, 2008

Rod Johnson: "Can Ruby on Rails do that?"

Adrian Coyler presented tonight's keynote at SpringOne.  Once again Grails was a large part of the presentation.  During the demo, he created a grails app from scratch.  Nothing new, we've seen it all before.  Easily creating a web application with minimal code.  However, the more impressive piece of the presentation was when Adrian integrated the application with an existing Spring Integration application.  

It was done with great ease.  Adrian performed the following simple steps to successfully integrate the existing application:
  • Copied all the spring integration jars into the grails-app/lib directory.
  • Copied the existing application's spring config file into the grails-app/resources/spring directory.
  • Added a "cafe" property to his Grails service in order to inject the existing application's spring bean.
  • Invoked the Cafe interface from the Grails service method.
That was it.  To which Rod Johnson commented from the crowd "Can Ruby on Rails do that?"  

I'd like to hear from the JRuby and Rails communities.  I have to believe there's a way to call an existing spring application bean via a Ruby on Rails app using JRuby.  Even if it requires some custom code.

Is it possible?  If it isn't simple, are there plans to provide tighter integration to allow organizations to re-use existing spring beans in Rails projects?

Tuesday, December 2, 2008

Grails Shines at SpringOne

Last night Rod Johnson kicked-off the 2008 springOne conference with a keynote emphasizing the new SpringSource slogan "Weapons for the War on Java Complexity."  During the first day of the conference, no technology fit that billing more than Grails.

In the first session of the day, "Grails for Spring Developers", Graeme Rocher wowed the crowd by building Twitter in 40 minutes.  It was really impressive to see how quickly Graeme created a full-blown twitter application including all the functionality twitter users are familiary with.  Not to mention the necessary application infrastructure including authentication, authorization, database persistence, caching, JMS messaging, Quartz scheduling, and email.

Graeme added each feature using many of the popular Grails plugins available today including:
By demonstrating these features, Graeme really backed up his statements that "Grails is more than just a CRUD framework" and that it offers "all the benefits of rapid application development without sacraficing the underlying power of Spring."  It appears that we may see more Grails integration with other Spring technologies such as Spring Dynamic Modules for OSGi and Spring Integration in the future.  Only time will tell, but Grails was mentioned by presenters in each of the presentations I attended today.

In Rod Johnson's keynote last night, he mentioned that in the last year, the number of Grails downloads have increased from 7000 to 70,000/month.  It may be a bit early, but it's starting to appear as though Grails truly is the future of enterprise java development.

Monday, December 1, 2008

Unit Testing Grails in Eclipse

For the past several weeks, I've been working on a Grails app in my spare time, and I'm really excited about the future of Grails.  However, I've been a bit disappointed in the tooling currently available.  Myself and many of my clients use Eclipse, and at this point the Eclipse support for Grails is less than ideal.

Spring Source's recent acquistion of G2One will really help move the Eclipse support forward.  Here's a recent interview with Grails founder Graeme Rocher in which he discusses how Spring Source will help drive Grails tool support within Eclipse.

One of the largest frustrations I've had with the Eclipse plugin is the setup necessary to run a grails unit test.  After I first setup my grails project in Eclipse, I tried to create a simple groovy unit test and run it.  As with Java unit tests, I right clicked on the class and selected run as junit test.  Each time I ran the test I received the following error.

"Error running MyGroovyTest.groovy failed to find a class file, ensure the Groovy output folder is on the classpath"

After a lot of digging around I was finally able to work through these issues and figure out a way to execute grails unit tests within eclipse.  Here are the steps I used to get the tests working.  
  1. Right-click on the project and select Properties > Groovy Project Properties.
  2. Uncheck "Disable Groovy Compiler Generating Class Files"
  3. Modify the "Groovy compiler output location" to "bin-groovy"
  4. Select "Java Build Path"
  5. Modify the Default Output folder to "/bin" (I need to test this again to see if this step is required).
  6. From the same Java Build Path dialog select Libraries > Add Class Folder...
  7. Check bin-groovy.
  8. Now run the unit test by right clicking on the groovy file and it should work.
It's quite an involved process, but it works.  If anyone has a simpler solution, I'd be really glad to hear it.  I'm using Eclipse Ganymede, Grails 1.0.4, and Groovy Plugin  

Cleaning up these types of issues within Eclipse will be critical to the success of Grails, and I'm glad to hear that SpringSource and Grails will be focusing their efforts on tooling in the near future.