WARNING: This is outdated content that applies primarily to Tapestry 4, not Tapestry 5. |
Once setup correctly WTP is easy to use. However it can be a real pain to setup a new Tapestry project in WTP. This document exists to so that new users can setup WTP without hours of troubleshooting and experienced users don't forget anything.
Note: for some reason content assist does not work with the application specification. It is validated however.
Note: projects are deployed as part of the build process. You will have to manually initiate a build if you prefer to have Project > Build Automatically unchecked.
This How-To was written and tested with the following configuration:
Eclipse will launch with your machine's default JRE.
.application
, .page
, .jwc
and .library
extensions to the Text > XML nodeContentTypes.gif!
templates.xml
Note: these templates are configured to be available in empty files. You can make them available in any XML file by editing the template and changing Context to All XML
.
Registering the Tapestry XML DTD allows <ctrl>+<space> auto-completion when editing tapestry files
file:///
. Change this to jar:file:
!/org/apache/tapestry/parse/Tapestry_4_0.dtd
.!/org/apache/tapestry5/internal/services/tapestry_5_1_0.xsd
in tapestry-core-5.x.x.jar-//Apache Software Foundation//Tapestry Specification 4.0//EN
%20
' and replaced them with a '{{ }}' in step 5.3 because that was whatThis tells Eclipse where Tomcat is installed.
TomcatServerRuntime.gif!
NewServer.gif!
NewServer2.gif!
A side-effect of creating a Server Configuration is a new Servers project will be created.
ServersProject.gif!
WTP does not automatically reload the context when page specifications and HTML templates are changed. If you set the Tapestry flag to disable caching you don’t need to restart the context to see changes. See http://jakarta.apache.org/tapestry/UsersGuide/configuration.html#N10106
-Dorg.apache.tapestry.disable-caching=true
to the VM arguments-enableassertions
if you use assertionsServerArguments.jpg!
The Dynamic Web Project is a part of WTP. It adds automatic deployment support.
NewDynamicWebProject.gif!
Note: You can open the J2EE perspective later via Window > Open Perspective > Other...
Note: I was unable to employ the* user library* approach for adding Tapestry libraries to the project. Tapestry was not loaded at runtime
lib
directory of your Tapestry installation (e.g. D:\tools\tapestry-4.0\ext-package\lib
)WebContent/WEB-INF/lib
. You can simply drag the jars to the lib
folder in Eclipse or do a file system copy (do a File > Refresh if necessary).WebAppLibraries.gif!
WTP automatically adds the libraries to the build path and publishes them for Tomcat to use.
Note by cyrille37: There is a way to add libraries at runtime without add them as real files in the web-inf/lib folder ; Have a look at Eclipse's WTP documentation: Adding Web library projects
Creating Tapestry specification files is easy using the XML templates we defined previously.
Home.page
)page spec
).ContentAssistPageSpec.gif!
Below are the files for the Hello World application used in the rest of this How-To. You can download these or re-create them from scratch.
WebContent/WEB-INF/
directorysrc
directoryAddRemoveProjectsDialog.gif!
Your project should appear under the server in the Servers view. It will be published when the server starts.
StartServer.gif!
HelloWorld.gif!
HelloWorld
to HelloMoon
insertHeading
from literal:Hello World
to literal:Hello Moon
The title and heading should now say Hello Moon
. If this is not the case then there is a problem with the org.apache.tapestry.disable-caching
VM argument.
Home.java
return "Hello World";
to return "Hello Moon";
The text should now say Hello Moon
.
Some things you can try if your project is not running as expected
StopServer.gif!
Eclipse will restart and reload your current workspace
During a build, WTP copies all deployable resources to a temporary directory. Tomcat loads the site from here. Sometimes it may become unsynchronized (particularly if you modify a jar while the server is running). Doing a clean build and restarting the workspace should take care of any synchronizing problems you have. But if you're still having problems you can examine the deployment directory.
INFO: Installing web application at context path from URL file:D:\TapestryDemo\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\ROOT
.Make a small change to the specification file and resave it. Reload the page in the browser. In his book Enjoying Web Development with Tapestry Kent Tong reports the cause of this probem as Windows caching the file.
Please, correct my poor english (Cyrille37)
Some times I add to erase WST.Server temporary deployement files because the "Run as Server" never copy files like home.html and more...
Stop Eclipse then
Erase file :
D:\evote.java\essais.withServer\.metadata\.plugins\org.eclipse.wst.server.core\publish.xml
and folders :
D:\evote.java\essais.withServer\.metadata\.plugins\org.eclipse.wst.server.core\publish D:\evote.java\essais.withServer\.metadata\.plugins\org.eclipse.wst.server.core\temp0
Then restart Eclipse.
This can happen when the Tapestry libraries are missing