Added by Howard M. Lewis Ship (Admin), last edited by Howard M. Lewis Ship (Admin) on Apr 28, 2009  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

A common starting point for tutorials using Tapestry is to say "create a new, empty project using the quickstart archetype". Ideally, you should be able to do that entirely from within Eclipse. This document describes how to go from nothing, to a running application inside Eclipse.

The baseline here is to have a recent Eclipse install (I used Ganymede).

You will also need to install two plugins:

  • m2Eclipse: The Maven Eclipse plugin, which allows Eclipse to understand the Maven pom.xml file, download dependencies on the fly, create new projects from archetypes, and use custom editors (rather than XML editting of POM). Available from Eclipse update site http://m2eclipse.sonatype.org/update/.
  • RunJettyRun: Allows you to run the Jetty servlet container inside Eclipse, directly against your source files. Available from Eclipse update site http://run-jetty-run.googlecode.com/svn/trunk/updatesite.

One of the best features of Maven is that it will automatically download dependencies as needed. Better yet, Maven will download the sources for dependencies and connect those up. This is great for debugging, as you can step into Tapestry code. In any case, you have to tell Maven that you want the sources. This is done inside the Preferences panel:

In addition, you want Eclipse to know that Tapestry templates are XML files. This is also done in the preferences panel:

Tapestry template file have a ".tml extension, so you need to associate "*.tml" with the XML content type. Once this is done, opening a Tapestry template file will bring up the full XML editor.

At this point, you should be able to create a new Tapestry project from within Eclipse. There are two obstacles. First, the Tapestry quickstart archetype is not (yet) in the default list of Maven archetypes, so you need to use an alternate Maven archetype catalog. Second, the M2Eclipse plugin has a bug (at the time of this writing, April 2009) where it is unable to properly read remote archetype catalogs.

To solve this problem, we will download a copy of the archetype catalog locally and point Maven at the local file.

Tapestry maintains an archetype catalog with just the quickstart archetype; it is at http://tapestry.formos.com/maven-repository/archetype-catalog.xml.

You need to download this file and store it on your local filesystem; I chose to store a copy in my Desktop folder.

From the New Project wizard, select "Maven Project":

You'll be presented with the default list of archetypes, which does not include Tapestry's quickstart.

Click the "Configure..." button (upper right corner) to configure the list of archetype catalogs. Then click "Add Local Catalog ..." and enter the location of the file you downloaded earlier.

With the local archetype catalog setup, we can choose it in the drop down list. Quickstart should be the only one listed (but don't be surprised if the version number is somewhat different):

After clicking "Next >" you will configure the details for the new project:

The new project will be created and you can start to look at what was created:

Now we're ready to run the application. Choose "Run Configurations..." from the Launch toolbar icon (the green circle):

Create a new "Jetty Webapp" launch configuration. Tab over the the Arguments panel and add -Dorg.mortbay.jetty.webapp.parentLoaderPriority=true as a VM argument.

That's it! Click the run button, browse over to http://localhost:8080/ and check out what the quickstart archetype has provided.

Thank you so much for putting this page together. I am new to Maven, Tapestry, and Jetty. This page has helped me a lot. I should take a minute for those newbies like me to point out that the JEE version of eclipse is the version that should be installed. I should also note that you must update the eclipse base software before it will let you install the Maven and Jetty plug-ins.

I still have one issue that I am trying to work through and would welcome any help that I can get. After following the steps in this document, I am not able to run the project yet. Eclipse is telling me that I have 22 errors in the project. All the errors are coming from the Layout.tml file in the web/components folder. I have gone thorugh and removed all the test portions of the project and got the number of errors to 11. Below are a few examples of the errors.

1. Attribute "source" must be declared for element type "li".

2. Attribute "xmlns:t" must be declared for element type "html".

Posted by Randy Schindler at Apr 11, 2009 09:35 Updated by Randy Schindler | Reply To This

OK - I deleted everything and started all over. I got rid of the errors, but I still cannot access my app through my browser. The console displays messages to me that show that everything is running, but when I open my browser I get a page cannot be found message.

Any help would be appreciated.

Hi,

If I try the release catalog http://tapestry.formos.com/maven-repository/ (non a snapshot), I have a list of errors similar to the list reported previously by Randi Schindler.

If I try the catalog http://tapestry.formos.com/maven-snapshot-repository/ (as recommended in this article), Maven complains:
     Missing indirectly referenced artifact org.codehaus.woodstox:woodstox-core-asl:jar:4.0.3:compile

Seems there's a dependency not resolved. Any idea?

Thanks

Richard Gomes http://www.jquantlib.org/index.php/User:RichardGomes

Posted by Anonymous at Apr 15, 2009 17:07 | Reply To This

I've just redone this using an updated archetype-catalog.xml (from http://tapestry.formos.com/maven-repository). Everything works fine for me, starting with an empty ~/.m2/repository. I'm using Eclipse Ganymede. Wish I could help more, but this definitely works. I'm not sure if there are other settings (related to the XML editor) that may be causing you grief.

This tutorial works fine for me.

Thank you!

German Blanco

Posted by Anonymous at May 03, 2009 00:21 | Reply To This

Hi Howard,

I'm trying to run the tutorial but I am stuck at one point.

After creating the maven project I go to "Run Configurations.." but I can not create a new Run Jetty Run config because the project created by maven is not a java web app (it has no the WEB-INF folder containing a web.xml file as required by the plugin) and the webapp dir is not found.

Anyway, I have rightclicked "Run As" > "Maven Build ..." and then Goals: jetty:run and Run and everything has worked ok. The url being http://localhost:8080/test1, adding the project name.

Is there a way to make your "way" work? Should the archetype produce a web app?

Thanks

Jose

Posted by Anonymous at May 10, 2009 15:33 | Reply To This

Please,
Forget about my last comment.
I found the webapp inside src/main/webapp
Jose

Posted by Anonymous at May 10, 2009 18:11 | Reply To This

Hi Howard,

this file http://tapestry.apache.org/schema/tapestry_5_1_0.xsd is missing on the server!

Regards

LinuxLuigi

Posted by Anonymous at May 11, 2009 06:48 | Reply To This

I just updated the M2Eclipse plugin and also saw that the Tapestry 5.1.0.5 archetype is visible in the Nexus archive so there's no longer a need to download the catalog to the local file system. I'm working on other things right now, but hope to update this page soon.

After a long silence (from my side) I'm returning to give the feedback that the instructions are working fine to me.

I'm using Eclipse 3.5 Galileo on Solaris 10 with JDK1.6.0_14.
I had to adjust the project's execution environment because it is J2SE5 by default.

Thanks

Richard Gomes http://www.jquantlib.org/index.php/User:RichardGomes

Posted by Anonymous at Jun 29, 2009 18:55 | Reply To This

Concise, well-written and 100% accurate.  Excellent use of screenshots.  Keep doing what you're doing, it helps more than you know.

Posted by Anonymous at Aug 08, 2009 18:10 | Reply To This

Hello, thanks for the tutorial.

I'm having a problem with the Run Configuration. It tells me that the Keystore file doesnt exist and I'm not sure how to create one.

Posted by Anonymous at Sep 18, 2009 14:53 | Reply To This

nevermind. I just used java keytool to create one.

Posted by Anonymous at Sep 21, 2009 12:40 | Reply To This