Category Archives: Grails

Roo vs Grails

We had a requirement where we had an application in production and was developed in Spring MVC and the velocity of implementing new features were slow. We had to explore alternate frameworks like Grails and Roo. I personally spent close to a month exploring which one was better.

We explored following features in both these and below is our findings. We explored following features in both these and below is our findings. The final verdict is we have still not finilized on either one, we are still exploring

  • Support for database migration from existing application to these frameworks
  • Support for Spring Security with existing user authentication/authorization model for these frameworks
  • Support for standard features like reporting
  • Support for ajax frameworks like JQuery, Dojo, GWT, Flex

Both of these frameworks are well integrated with STS IDE. If you have to use these framework, configure STS IDE and start developing, dont use command line, you cannot take advantage of roundtrip code generation capabilities.

Roo:

This framework is 100% Java roundtrip engineering RAD framework which is used to develop any Spring application including web application using Spring MVC, and Ajax based views. The deal breaker here was, Roo was very buggy. It has addon for lot of tools like Jasper/ JQuery/Flex etc.. but most of them wont work out of the box with 1.2.1.RELEASE. It is wasy to build a simple prototype but build or reverse engineering enterprise web appliction is not easy. One aspect favorable to it is since it is Java based, people who understand Spring MVC, Spring Webflow etc, can take advantage of it.

Support for database migration from existing application to these frameworks:

In Spring Roo 1.2.1.Release database reverse engineering the database to DAO, DTO comes out of the box, the roo command is as below,

database reverse engineer --schema PUBLIC

Support for Spring Security with existing user authentication/authorization model for these frameworks

When you run the command security setup it will provide all the security plumbing including a login page and default spring security context file.

If you have to customize it, you need to configure in the spring applicationContext-security.xml file as below,

<http auto-config="true" use-expressions="true">
	<form-login login-processing-url="/resources/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t" />
	<logout logout-url="/resources/j_spring_security_logout" />
	<!-- Configure these elements to secure URIs in your application -->
	<intercept-url pattern="/users/**" access="hasRole('admin')"/>
	<intercept-url pattern="/roles/**" access="hasRole('admin')"/>
	<intercept-url pattern="/userrolesmaps/**" access="hasRole('admin')"/>
	<intercept-url pattern="/" access="isAuthenticated()" />
</http>
<!-- Configure Authentication mechanism -->
<authentication-manager alias="authenticationManager">
<!-- SHA-256 values can be produced using 'echo -n your_desired_password | sha256sum' (using normal *nix environments) -->
	<authentication-provider>
		<jdbc-user-service data-source-ref="dataSource"     users-by-username-query="select email_id, password, active
		from custom_user where email_id=?"
		authorities-by-username-query="select u.email_id, r.name from custom_user u, custom_role r, custom_user_roles_map ur
		where u.id = ur.user_id and ur.role_id=r.id and u.email_id=?  " />
	</authentication-provider>
</authentication-manager>

Support for standard features like reporting

There is already an addon in Roo for Jasper reporting from gvnix, sadly this did not work out of the box, I had to write a new controller to plug into Jasper using Maven and write ton of code

Support for ajax frameworks like JQuery, Dojo, GWT, Flex

Again I was not able to make Flex work with Roo out of the box. Dojo comes bundled with Roo out of the box and it is Ajax enabled. Roo also works with GWT, but making Spring Security work with GWT was a challenge. There is no addon to JQuery.

Grails:

This framework is Groovy based, there is a learning curve involved for Java / Spring MVC developers to learn this new langauge, but let me tell you it is worth an effort. This is purely a web development platform. And among these 2 frameworks, this one is more stable and has better overall addon support with minimum bugs. There is also good JQuery /Ajax support.

Support for database migration from existing application to these frameworks:

There is a db-reverse-engineer addon, which can create a whole set of plumbing like Dto, Dao etc in Groovy

Support for Spring Security with existing user authentication/authorization model for these frameworks

It does provide spring security support with sample user authentication groovy code ready to be use, but if you want to configure it to work with existing schemas, it was not easy. And there is not lot of documents on the web to show how to implement

Support for standard features like reporting

Still exploring

Support for ajax frameworks like JQuery, Dojo, GWT, Flex

Still exploring

Jumpstart Grails with real life example: Agile Tracking Tool

Recently I wanted to tryout Grails. I was trying out lot of different sample/examples/opensource projects. With the new Grails 2.0.3 upgrades all these applications are not working out of the box including Grails sample. Finally I narrowed down to on opensource project – Agile Tracking Tool. Within an hr or so I was able to make this work on Grails 2.0.3. It clearly demonstrates aspects like,

  • Spring Security
  • Graphs and Charts
  • Ajax using prototype framework

I am also contributing to this code base, by making it working with Latest Grails and I am currently fixing Authentication/Authorization with roles like, admin, scrummaster, developer etc..

To quickly jump start setting up the environment,

  • Download the latest grails @ http://www.grails.org/download/file?mirror=212
  • This assumes that you have Java 6 installed on your machine, and add <grails installation folder>/bin folder to the path
  • Get the latest code @ https://agiletrackingtool.googlecode.com/svn/trunk/ using tortoise svn
  • open the command prompt and go to the folder you just now got the code and run grails run-app
  • Open the browser and type in http://localhost:8080/AgileTrackingTool/
  • Login in as scrummaster/scrummaster and load the sample data by clicking the link “Load example project data”, also notice you dont have admin link
  • Once you load the data, you can see some burndown charts etc..
  • Login in as admin/admin, you get the admin link

Next step is to import this project in STS IDE as a Grails project and analysing how charts work, how ajax work etc…