Skip to content

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.

C:\Dev\projects>mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org

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

Choose archetype:
1: http://tapestry.apache.org -> quickstart (Tapestry 5 Quickstart Project)
2: http://tapestry.apache.org -> tapestry-archetype (Tapestry 4.1.6 Archetype)
Choose a number: : 1
Choose version:
1: 5.0.19
2: 5.1.0.5
3: 5.2.6
4: 5.3.7
Choose a number: : 4
Define value for property 'groupId': : org.dontpanic
Define value for property 'artifactId': : tapestrydemo
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  org.dontpanic: :
Confirm properties configuration:
groupId: org.dontpanic
artifactId: tapestrydemo
version: 1.0-SNAPSHOT
package: org.dontpanic
 Y: :

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

C:\Dev\projects>cd tapestrydemo
C:\Dev\projects\tapestrydemo>mvn jetty:run

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

http://localhost:8080/tapestrydemo/

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.

Published inHow ToJava Technologies

2 Comments

  1. […] while back when I was learning Tapestry 5, I was astonished at how easy it is to create and run a demo Tapestry 5 project using the Tapestry Quickstart Maven archetype. One of […]

Leave a Reply

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