A few years ago I was writting some simple tutorials about using hibernate with tapestry to build a simple application. I’ve used Tapestry 3, 4 and I found it reliable to build applications which are still in production. I could consider myself a Tapestry fan and as such I am disappointed a bit to write this article since I was expecting to find no need for it. My goal was to build a simple example of Tapestry – Hibernate application using Tapestry 5.

1. First try: the maven method recomended on the site:

$ ./mvn archetype:create -DarchetypeGroupId=org.apache.tapestry  -DarchetypeArtifactId=quickstart -DgroupId=org.apache.tapestry -DartifactId=tutorial1 -DpackageName=org.apache.tapestry5.tutorial
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:create] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:create]
[WARNING] This goal is deprecated. Please use mvn archetype:generate instead
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: quickstart:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.apache.tapestry
[INFO] Parameter: packageName, Value: org.apache.tapestry5.tutorial
[INFO] Parameter: package, Value: org.apache.tapestry5.tutorial
[INFO] Parameter: artifactId, Value: tutorial1
[INFO] Parameter: basedir, Value: /phantom/java/kits/apache-maven-2.1.0/bin
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] <span style="color: #ff0000;">Error creating from archetype

Embedded error: The META-INF/maven/archetype.xml descriptor cannot be found.</span>
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds

I’ve found the track in jira for this but the fix is in the next release.

2. Well I don’t like maven anyways but I am sure I will be able to find some examples. And I found some indeed:

They work ok with the 5.0.* version of Tapestry but since current version is 5.1.0.5 I thought stupid to use an old version and not the latest so I just replaced the jars:

  • tapestry-core.jar
  • tapestry-ioc.jar
  • commons-codec.jar
  • tapestry-annotation.jar
  • javassist.jar
  • slf4j-api.jar
  • slf4j-log4j12.jar

with their newer version. At this time nothing worked and I got a very “suggestive” error:

SEVERE: Error filterStart
Jun 14, 2009 8:37:56 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/test] startup failed due to previous errors

A google search revealed nothing so I was left over with the task of just finding which jar was required from the list of jars coming with Tapestry archive. Finally I was left with this list:

  • antlr-runtime.jar
  • tapestry-core.jar
  • tapestry-ioc.jar
  • commons-codec.jar
  • tapestry-annotation.jar
  • stax2-api.jar
  • woodstox-core-asl.jar
  • javassist.jar
  • slf4j-api.jar
  • slf4j-log4j12.jar

This restored the applications.

3. I thought making tapestry work with hibernate would also be a simple task but again jar dependencies generated strange errors from the filterStart error to other strange ones. After some more time of jar finding here is the final list to make a simple hibernate example also work:

  • antlr-2.7.6.jar
  • antlr-runtime-3.1.1.jar
  • commons-codec-1.3.jar
  • commons-collections-3.1.jar
  • dom4j-1.6.1.jar
  • ejb3-persistence.jar
  • hibernate3.jar
  • hibernate-annotations.jar
  • hibernate-commons-annotations.jar
  • javassist-3.9.0.GA.jar
  • jta-1.1.jar
  • log4j-1.2.14.jar
  • postgresql-8.3-604.jdbc3.jar
  • slf4j-api-1.5.2.jar
  • slf4j-log4j12-1.5.2.jar
  • stax2-api-3.0.1.jar
  • stax-api-1.0.1.jar
  • tapestry5-annotations-5.1.0.5.jar
  • tapestry-core-5.1.0.5.jar
  • tapestry-hibernate-5.1.0.5.jar
  • tapestry-hibernate-core-5.1.0.5.jar
  • tapestry-ioc-5.1.0.5.jar
  • woodstox-core-asl-4.0.3.jar

At the end I lost a lot of time making this work but even so I liked what I found, too bad it was not very easy to get here and in all some stupid list of dependencies would have made all the difference.

Comments:

aditsu -

That reminds me of http://www.youtube.com/watch?v=PQbuyKUaKFo :) (I’m not a RoR fan though, I use java too)