Tapestry Quickstart

As preparation for a recent interview, I decided to attempt to download, install and run an example Tapestry web application. I set aside a couple of hours to get this going. I expected to have to download an installation bundle, extract it, run an installer, install some dependencies, install and configure a webserver, start some services, write some code, debug, swear a bit then give up and just read an online tutorial.

As it happens, all you need is Maven 2. Running two goals with no particular config will download Tapestry and all dependencies, build and deploy a sample webapp and then run it in a webserver (which it will install too!).

Step 1:  Run quickstart archetype goal

This will create a simple Tapestry Maven project for you.

It will ask you some questions. Not too many and the answers are all easy:

First, it asks to to pick an archetype and version number. Unless you’ve good reason not to, pick the latest versions. The groupId and artifactId will be used as your new Maven project identifier. The default version number is just fine. It will default the Java package name to your groupId. Then press enter to confirm your choices.

Now is a good time to make some coffee as Maven downloads Tapestry, its dependencies (and its dependencies’ dependencies) and possibly Maven’s own dependencies for the archetype plugin. It took about ten minutes for me.

When it’s done, you’ll find a simple (but completely functional) Tapestry webapp in a folder called tapestrydemo (or whatever your artifactId was). Now the hard bit, getting it to run in a webserver…

Step 2: Run the jetty:run goal

That’s it. No really. This will download Jetty (and its dependencies, and its dependencies’ dependencies… you get the idea), configure it for your new Tapestry demo webapp and start it. Once it’s finished downloading everything and churning away, you can see it by browsing to

Step 3: Play!

I found myself with around one and three quarter hours left of my two hour slot to play with Tapestry. I just wanted to fiddle with some settings and variables to get an idea of how it all hangs together. I found the Tapestry Tutorial #1 pretty good. EDIT: The Tapestry Tutorial #1 is no longer available. Other tutorials are available from the Tapestry website but I’ve not yet tried them.

From what little I’ve seen, it seems to hang together very well. It seems a nice example of convention over configuration. There’s very little configuration – components just connect in what appears to be an obvious way.

As if the ten minute setup time wasn’t good enough, Tapestry allows deployment of changes without having to recompile anything. So I modified the index page’s Java class in Eclipse, saved it then reloaded the page in the browser. Sure enough, my change was visible immediately. No recompile, no webserver restart. Lovely.

My only frustration here is that I could get this working only in Eclipse. If I modified the file in a plain text editor or IntelliJ IDEA, the magic didn’t work. I’ll most likely investigate this once I’ve used Tapestry a little more and understand it better. For now, I’m happy to believe that the Tapestry magic pixies just prefer Eclipse.

Leave a Reply

Your email address will not be published. Required fields are marked *