I invested a lot of hours to find out how to configure Eclipse Ganymede in a way where it works well in a JEE Facelets Project. Currently development of Facelets Web apps is not supported by the Eclipse IDE and WebToolPlattform (WTP). I am not sure but maybe the Eclipse WTP Team did not like Facelets developers. It is not easy to get things like code completion for xhtml files to run out of the box.
So this is my story how I configure a Eclipse Workspace to work with a JEE facelets web project.
I am using Eclipse Ganymede, Glassfish V2 and Maven2. These are the steps I go through:
1.) Install the Eclipse Facelets Plugin
The Eclipse Facelets Plugin is the key to develop xhtml files in eclipse. But it is brand new and - in the moment - not available trough the eclipse update manager.
The Plugin allows you to work in xhtml files like in JSP files. You got code completion and also some nice template wizzards. This plugin is very useful if you want to develop a JEE Web Facelets Application.
If you are interessted in the project - this is the project homepage:
And in this webinar you can see the cool features of the plugin:
But in the moment it is very difficult to get the plugin. If you are not familiar with plugin development, checkout plugin source code from eclipse, compile and export plugins it become very hard.... :-(
So I download the sources and compiled the plugin code with the eclipse IDE. If you don't want to go this way you can download the plugin from here.
Extract the file and copy the jars into your /plugin folder of your Eclipse Ganymede. Next restart Eclipse!
2.) Setup Workplace for JSF Support
Now you need to do some configurations to support Eclipse with the necessary Server Environment and JSF Libraries. This is not a project specific configuration but a workspace specific! So if you start in a new Workspace you need to repeat these steps.
First add your Glassfish Server to the Server list. Switch to the Server View and add a Glassfish V2 Server. You need this server environment (target runtime) later in your web project.
Next stp is to add the JSF Implementation form Glassfish to your Web JSF Configuration. This is explained also by Cay Horstmann's Blog:
So open the Eclipse preferences dialog and go to Web->JavaServer Faces->Libraries.
Create a new JSF library and name the library "GlassfishJSF-impl". Add only the jsf-impl.jar file. This file is located in the /glassfish/lib folder from your glassfish installation.
Now Restart you Eclipse! (I beleve this is a important step).
3.) Setup your Web Project
Now this is the most critical part. And I am not sure if every step is really necessary but it seems to work for me.
So open your Web Project (or create a new one) and open the project properties. Go to "Project Facets".
Here you can now add the "JSF 1.2" and also the new "Facelets 1.0" support:
You will see a link "Further configuration required". Click on it and configure the dialog like this using the server configuration from Glassfish:
You will not see this configuration page again after you close the property dialog! So be carefull. The only way is to disable the Faclets and JSP Support - apply the settings - and re enable the settings again! (It seems to me that this is a plan from the WTP Developers to craze JEE Developers)
Next check the "Java Build Path" settings of your Web Project. You need to add two libraries to your project.
The Server Runtime Library of Glassfish (automatical created during adding the Glassish Server to the Server list before)
Click "Add Library..." and select "Server Runtime"
Choose the Glassfish Server from the Server Runime list. Click finish.
Next you need to add the JSF Library created before. So click again "Add library..." and add a JSF Library and select you GlassfishJSF-Impl created before:
Finaly your project library settings should look like this (Maven Dependencies is only visible if you work in Maven2 project as I do)
Next check the Order of the Libs! This seems also to be very important:
Make sure that the Maven Entry is at the end of the list!
Now restart your Eclipse! If you are lucky you can now edit xhtml files with code completion support :-)
If it did not work...
But! When you work with Maven2 Projects and your xhtml files did not support code completion you need to check some things. I did not know while the project settings will not work after first configuration. I followed these additional steps:
1.) update you maven configuration of your web project
->maven->update project configuration
2.) check the order of the libraries
3.) check if you have added the a target runtime for glassfish and also the glassfish JSF-Impl. You can select the glassfish Server as your project target.
3.) Restart Eclipse and wait as long as all background jobs are finished before you test you xhtml editor.
So I hope this will helpe someones - every comments are wellcome!