Eclipse 3.6 + STS Nightly build + Grails 1.3.2

When I was starting to learn Grails, I really wanted to use Eclipse but because of the lack of support for Groovy and Grails at the time, I chose Netbeans over Eclipse.  It was thet rational choice for me at the time because 1) I was having a hard time with Groovy and Grails in Eclipse and 2) Jetbrains' IntelliJ was too expensive for me.  

Recently, Eclipse 3.6 (aka Helios) was released so I decided to revisit Eclipse, which is my favorite IDE.  The problem I had with Netbeans is that it is painstakingly slow!  Grails/Groovy autocomplete and plugin manager takes around 5-10 seconds to load so I ended up looking at the API instead of relying on the autocomplete.

Anyhow, I downloaded Eclipse 3.6 from http://www.eclipse.org/downloads/ and followed the instructions in http://dist.springsource.com/release/STS/doc/STS-installation_instructions-2.3.3.M1.pdf ,page 9. It was a joy to see the improvements made to integrate groovy and grails with Eclipse.

One problem I encountered was the Missing Class error relating to org.apache.tools.ant.taskdefs.optional.native2ascii.  I've read in a blog that it was caused by a JAVA_HOME system variable pointing to the JRE instead of the required JDK.  I checked my JAVA_HOME in the Advanced Settings of the Properties of My Computer but it is pointing to the correct JDK.

After a while, found out that my Installed JRE in my Eclipse's preferences was pointing to the JRE.  After I added my JDK and set it as the default one, the problem was gone (see image below).  

Eclipsejdk

So far so good, I hope I won't be needing Netbeans anymore. :)

--
References:
http://blog.springsource.com/2010/07/01/sts-on-eclipse-3-6/
http://www.morkeleb.com/2009/04/04/grails-error-starting-suns-native2ascii/ 
http://dist.springsource.com/release/STS/doc/STS-installation_instructions-2.3.3.M1.pdf  

My Grails is up on Google App Engine

I accessed my test site http://testfoodams2.appspot.com recently and it's now working!  The first access was slow, but the point is it's not giving me the dreaded 500 error. I guess Google might have done some bug fixes.  I'm excited, I originally wanted to work on Google App Engine (GAE) because it's free, but I was turned off because it was giving me timed out errors often.

One problem though, I checked my GAE panel and each domain controller's listing is using too much CPU usage.  I just accessed the views that list all my records on a certain domain object and I was already reaching my CPU usage limit for that particular page.  I'm not yet sure if the problem lies in GAE or in Grails.  My hunch is that grails needs to be optimized.

Hosting a Grails Application up in the Cloud?

Introduction

As discussed in my previous post, I chose Grails as my Java Web Application Framework.  If you don't know much about Grails, I suggest you read my previous post first.

Java is considered heavyweight in the field of web apps. It is powerful yet it takes more horsepower to get it running than a lightweight application, say, one done in PHP.  For this reason, it is often more costly to host Java web applications.

Then came "Cloud Computing". This has changed a lot of things.  For one, the average Joe can now host a fast and scalable application using the services offered by various Cloud providers. Come again? Read on.

"Cloud Computing" is defined in Wikipedia as computing done on the internet with shared resources given to end-users upon demand. With cloud computing, you won’t have to worry about setting up your own server before you can deploy an application. You won’t even have to worry about maintaining it and tuning it to live up to your application’s requirements and customers’ demands. Cloud service providers have already done and will keep doing this for you… so long as you pay your rent.

Just imagine your web application being copied to a farm of computers.These computers can work together to deliver your services to a whole lot of users on the internet. And since your applications is hosted by many servers, it allows your application to scale fast and serve millions of simultaneous users and you won’t have to worry about your application breaking or slowing down, cet par.

With the above in mind, if I want to create an application capable of serving many users, hosting it in the cloud is the way to go.  Various cloud service-providers are out there.  Again, it's a matter of choosing which one, and this is very important because chances are, you’ll end up getting tied up to their API.  What does this mean? It means you can’t just plug in an already existing application to a service provider, say Google, nor can you switch easily from one to another. Why? For one, storing information is different in Google. Also, there are many limitations and security restrictions which you’ll have to consider before deploying your app in the Google cloud.

 

Cloud Providers

Having said the above, I decided to choose my host first so as to consider any limitations or additional requirements before designing my application.

Here are some of the Cloud service providers I’ve encountered:

Google App Engine

As the name says, it is a service offered by Google.  Originally, they only hosted Python applications, then they released a beta supporting Java applications… and I was hooked.  

It offers a great pricing system: it’s initially free!  Billing is introduced as your application scales up.  This is great news for developers as you can try running toy applications on the cloud.  Their billing system is very specific to what components you will be needing like CPU Usage, Storage, etc, so this is also a plus.

The downsides are the limitations, security restrictions, and the proprietary storage solution.  Go to their website for more information. 

Currently, Java hosting is still plagued with issues. I will discuss in one of my succeeding entries how disappointed I was when I used Google.  

 

Amazon EC2 

I believe Amazon is way ahead of the others when it comes to offering Cloud hosting solutions. History has it that Amazon was the first to make use of the cloud architecture in a computer network. They also offer a very flexible solution compared to that of Google.  The only big letdown is the pricing.  It's just too expensive for me. 

 

Microsoft Azure

I can't really say much about Microsoft Azure, but I've read that you can only develop sites using their API (but it's very extensive).  They’ve already added Java support but I'm assuming Microsoft Azure is better suited for Microsoft-oriented products and services.  They have a tempting introductory offer where you can use their cloud for free.

 

VMForce

When VMWare recently announced its tie-up with SalesForce to create a Cloud Service, I was thrilled because VMWare already owns Grails, which means this cloud service will more likely have great support for Grails. Sadly, this service is not available yet.  It is expected to be available by Fall of 2010.

VMForce claims to be the first Enterprise Cloud for Java developers.  I don't exactly know what that means but it's music to my ears.  I will watch this closely.

 

Rackspace Cloud

Grails.org uses it, so they probably believe in it.  I have seen many sites hosted by Rackspace cloud and they seem to perform very well, and are very responsive, at that.

 

Morph Appspace

This has a direct support for Groovy and Grails but hosting is very expensive.

 

Stax

Also has direct support for Grails. They are still in beta so hosting is currently provided for free.  As of writing, they have not announced any pricing schemes.

 

Joyent

I have nothing to say about Joyent.  Visit their site for more information. 

 

GoGrid

I have nothing to say about GoGrid.  Visit their site for more information. 

 

Conclusion

There are many Cloud providers out there and it’s time we took advantage of it.  I have yet to decide where I will host my Grails applications but I'm currently considering Google App Engine, Rackspace Cloud, and Stax. I’ll keep you posted.

 

--

References:

 

Why Grails vs Spring MVC, Struts 2, Tapestry, Wicket, JFS, Stripes, Seam etc?

Introduction

Have you thought of a new service or application, probably your "next big thing" or THE NEXT BIG THING? If so, then we are on the same boat. The next problem is how will you build it?  It also depends on your programming language, but I will be focusing on Java.

It is in my best opinion that you are better-off using a framework in achieving your goal. Sure you can use the standard Servlet and JDK but if you plan on creating a web application it is beneficial to have a set of tools that are already available and free so that you won't have to create everything from scratch and focus on what is more important, your "next big thing". 

Java developers are open to a huge variety of web frameworks but as a human, you arguably cannot master all of them.  There are two reasons why I believe this is a great time for Java developers to get to know new standard frameworks:

1) Maturity.  As of writing, many of the new frameworks seem to have matured; they are ready for enterprise.  

2) Java is inching its way to mainstream.  Performance is becoming trivial because of new innovations like cloud computing, but this discussion is for another time.

 

Different Java Web Application Frameworks

Before I chose Grails, I read a lot of articles and reviews about the new frameworks that are readily available.  I am not adept with many of the new frameworks listed here although I have tried working with Struts, Hibernate, Java EE, Spring, and now Grails.  What I will write is my own biased opinion and a quick summary of what I have read:

Tapestry. Wicket, Stripes
I've put them together because I can't say much about them and I’ve eliminated them from list immediately. Tapestry has a steep learning curve and release periods are long.  Wicket, too much Java, even html is in Java. Stripes is unknown for me.

Because of my experience, I am more inclined to use one of frameworks below. Also, these frameworks would more likely get you a job (see references). 

Standard Java EE
Java EE is the sun standard for building Enterprise web applications.  Well, their standard is not that intuitive for me and it still takes a lot of work to build an application.  This is better suited for firms with lots of workers as they can assign teams per component and integrate them later. But for an individual like me, it's a No.  Java EE standard also makes use of JSF, a tag library framework which takes care of the Java EE's presentation layer for better re-usability and a more "sound" programming.  My opinion?  Yes, the tag library is useful for the basic web controls but customizing it will take you a considerable amount of time.

Seam
Seam is not really a web framework, it's more of a layer for abstracting the new frameworks out there.  The way I see it, they get the best of the components from several frameworks and put them together seamlessly (thus the name, duh!).   I considered using this because it looks promising. But again, it's still too complicated and not intuitive for me (personal preference).

Struts 2
Although Struts (1), authored by Craig McClanahan, helped in building a big portion of enterprise applications to date, it is already considered obsolete by many, including me.  I think it happened a few years after the release of Java 5 where developers took advantage the significant improvements in Java in addition to the vast knowledge learned in struts to create new and better frameworks.

Struts 2, which emerged from Struts 1, offers a simple architecture and customizable tag library.  It is supposedly the successor of the very successful Struts but as far as I know the architecture is very different.

Spring MVC
Many are now developing enterprise web applications in favor of using Spring MVC, which is arguably better than Struts (See References).  There are countless debates arguing which is better. It just goes to show that both are very good frameworks so it will narrow down to your preference as a developer.

Both Struts and Spring MVC are based on a Model-View-Controller (MVC), a model proven successful in developing enterprise applications.  Most frameworks today follow the MVC model.

Grails
Built on top of Spring MVC, Grails is a web framework that harnesses the power of Groovy, a scripting language built on top of Java. It aims to make programming in Java dynamic and less cluttered, leading to productivity boost.

My pros and cons in using this framework.

Pros:

1) It follows a "Convention over Configuration" paradigm (see References) which I prefer.  Logical data model (db structure) is created for you, views are created for you, controllers are created for you… What more could you ask for?

2) Developing applications are amazingly fast.  With just a few codes, you can already have an up and running application with Create, Read, Update and Delete (CRUD) functionality.

3) Very good documentation.

4) Something new to learn at the same time: Groovy. 

Cons:

1) Learning Curve is a little steep (I think this is normal in learning any new framework, but still listing it under Con).  This framework is all about convention anyway, so you have to learn their convention but they are intuitive in my opinion.

2) It is still relatively new so the maturity is questionable but I believe it's already enterprise-ready.

In 2008, Grails was acquired by SpringSource, the creator of Spring.  However, I'm confused with Spring Roo. I think it's competing with Grails, at least with SpringSources' resources.  I hope they’d add more effort into developing Grails and making it faster and more flexible (e.g. Integration with Google App Engine).  As a side note, SpringSource was then acquired by VmForce in 2009, seems everybody is buying somebody nowadays.

 

Conclusion

This exercise of choosing the right framework has taught me several things.

1) I prefer Convention over Configuration.  As the statement implies, it reduces the number of configuration and repetitive tasks (especially those hellish xmls). (see References)

2) Framework is your friend.  Frameworks for rapid Java application development already exists, it's just a matter of choice.

3) And when you have critically selected the best possible choices and you’re still left with a handful, it all boils down to your preference.  Choose whichever you’re happy with.

To conclude, I have chosen to invest a considerable amount of time in learning grails because it agrees to what I believe in and I would like to believe that this framework has a very good future.

In the next topic, I'll be posting a prequel to starting my first Grails Application.

 

References: