Archive for February, 2007

Deploying Grails applications on Tomcat

I just saw this blog entry about deploying Grails apps on Tomcat.

I’m confused as to why there is a need to "grails run-app" on the server.

I have deployed Grails applications many times now on Tomcat 5.5 on remote servers that don’t even have Grails installed. All that is required is dumping the .war into the webapps directory. To avoid problems I shut down tomcat first, copy the .war over, and then start tomcat again. It works without fail.

Here’s my shell script for doing this:

#!/bin/sh
/etc/rc.d/init.d/tomcat5 stop
sleep 10
rm -Rf /opt/tomcat5-5.5.17/webapps/ROOT
rm -f /opt/tomcat5-5.5.17/webapps/ROOT.war
cp /home/marc/ApplicationName.war /opt/tomcat5-5.5.17/webapps/ROOT.war
/etc/rc.d/init.d/tomcat5 start
 
  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

21

02 2007

Will Groovy work for the PHP crowd?

It feels like there has always been somewhat of a divide between PHP and Java development. A large number of PHP projects seem to be quick and dirty hacks with no regard for scalability or extensibility, but that is why it has been so successful. A sad fact is that most people in this world aren’t forward-thinking and just want a quick fix and they want it now.

You can do dirty hacks in Java but you have many more obstacles to overcome – you have to use Objects for start, compile them, deploy a web application etc.

It’s a no-brainer really to see how even a rather ugly scripting language like PHP can trounce Java in the web marketplace.

However it seems natural that an awful lot of people who previously lived in the PHP camp will defect to Ruby on Rails. I’ve not used Ruby or Rails yet, but I’ve read a bit about them. I can see exactly why PHP-style developers will find it attractive.

There appears to be some kind of anti-Java snobbery or psychological barrier to people deciding to learn and deploy Java. Maybe it’s hideous misconceptions of performance, complexity or limitations. I wager there’s quite a bit of urban myth and folklore among the younger website "hackers" who don’t spend time to actually discover the facts and just cite some ill-informed blog somewhere that said "Java performance suckz man".

Groovy has the potential to change this. It supports scripts, not just classes, which makes small jobs easier for everyone. In Groovy it is easy to write many constructs that feel cumbersome in Java. It is dynamic, and this appeals very much to the "coding by the seat of your pants" side of one’s programming persona – without the feeling of also needing a shower afterwards as when you use PHP.

The trouble is to leverage all the great libraries out there for doing web stuff – like RSS parsing, caching and rendering, Ajax, sending email – are in Java land. They are trivial to call from Groovy but they require you to cross the bridge from functional libraries (as most core libraries in PHP are) to often quite complex OO APIs.

I think that if you could download a single .tar.gz containing Java, Groovy, Jetty and a trivial groovy scripting servlet, that the prospects for Groovy and hence Java in the website space could be very different. Not everybody wants Rails… I imagine it is overkill for most "static" websites that just have a contact form or two.

These types of sites represent a very large part of the market and serve as the training ground for young developers. These sites will continue to be written in PHP for a long time I think, unless someone provides an "install and go" solution. Oh, and makes it palatable to all the ISPs in the world :(   **

For the moment at least, it looks like Ruby On Rails will be in the limelight for some time. The main gripes I’ve seen about it are related to performance and scalability, and lack of unicode support. For many applications these things don’t matter, or in terms of performance a new server can be added for relatively little outlay compared to the perceived development cost of using a Java based solution.

The web development market as opposed to the Enterprise market has always been dominated by lowering costs. That’s why people don’t want to have to spend long learning something, and want instant gratification. That’s what scaffolding is all about, even though it is often useless in real life applications beyond the prototyping stage.

So Java has the feel of a more "software engineering" solution, and PHP has a feel of "just getting things done". Perhaps the two philosophies will start to collide in Rails and Grails.

I hope that we will be able to make Grails an attractive solution to non-Java developers. Instinct tells me we have the performance edge thanks to Hibernate under the hood, and JIT compilation in the Java VM. It will be good to see hard stats on this one day.

** – which requires a custom servlet container I think, that makes it really easy to host multiple applications from multiple home directories, with controls over how they can affect each other in threading terms etc

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

21

02 2007

Grails simplifies spring controllers

I picked up on a blog post by Carl Fyffe, not somebody who I am familiar with but hey that’s the joy of Google blog search.

Carl gives Grails a nod and complains about problems handling different request types and how you need multiple controllers when using Spring MVC. Not so with Grails! Grails sits on top of Spring but adds value. In 0.3 support was added for restricting HTTP methods. Couple that with the support for multiple actions per controller and per-action HTTP methods, you get a solution I think Carl would enjoy. And guess what, no XML config. At all.

Here’s the example from Grails’ website:

class PersonController {

  // action1 may be invoked via a POST
  // action2 has no restrictions
  // action3 may be invoked via a POST or DELETE
  def allowedMethods = [action1:‘POST’,
                        action3:[‘POST’, ‘DELETE’]]
  def action1 = {}
  def action2 = {}
  def action3 = {}
}
 

 

 
  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

14

02 2007

Linkcheck your Grails application as part of your funcational test

Canoo WebTest author Dierk König pointed out to me that you can use Webtest which is well integrated with Grails to link check your site locally. This is a must-have functional test to include before deploying.

All you need to do is get webtest setup for your project by running

grails generate-webtest

It will prompt you for a domain class name – put any one of your class names in there, it doesn’t matter. You can delete the generated test afterwards.

After this is done all you need to do is add a test that does the link checking to ./webtest/tests:

class LinkTest extends grails.util.WebTest {
    void suite() {
        testLinks()
        // add tests for more operations here
    }

    def testLinks = {
        webtest(‘Link checker’) {
            invoke(url:‘/’)
            verifyLinks(depth:5, onsiteonly:true)
        }
    }
}
 

Then you just run the test:

grails run-webtest

…and then check the HTML report in webtest/reports

It would be great if we can get an integrated "release" Grails script that will provide the full workflow for releasing a new site version, including:

  1. Run unit tests
  2. If these pass, run functional tests
  3. If these pass, do full linkcheck
  4. If still going OK, increment version number
  5. Package into a .WAR

It would be very nice. A fair bit of work involved though.

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

13

02 2007

Truly amazing multi-touch display video

Now we’re all excited by iPhone’s multi-touch display, it seems it has opened the floodgates for discovery of projects working on this tech.

Look at this totally amazing video

The display is huge. The user interface mechanisms in the applications demonstrated are just wonderful and look incredibly natural. It’s not just multi touch, it’s multi user! multiple people using the same application at the same time on the same screen.

Check out the use of Google Earth (it appears to be the "standard" application with some input tweaks) and how they zoom and rotate on any axis.

Look at the momentum/intertia as they sweep away the photos they don’t want.

I want one now! The question is, will this make it into the home / small office (outside of the "mediacenter room") i.e. can they integrate this satisfactorily with a keyboard or can they make a new text input method that is as acceptable as a keyboard.

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

13

02 2007