Differences between revisions 5 and 6
Revision 5 as of 2006-01-03 12:21:00
Size: 3487
Revision 6 as of 2009-09-20 23:01:51
Size: 3487
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Myfaces Eclipse Setup

Myfaces application can be configured in eclipse and launched using tomcat/jetty servlet container. Lets assume a general web application directory structure:

  |      +---src
  |           +---java
  |      +---src
  |           +---java
       |      +---java
              |    +---classes
              |    +---lib
              |    +---web.xml
              |    +---faces-config.xml
              +---<view pages>

The <root>/lib folder contains Myfaces jars. Lets assume <root> folder is c:\workspace\myproject. Its a good idea to download various/all latest commons jars and put in a subdirectory under lib. Install the following:

  • j2sdk 1.5
  • eclipse sdk 3.1 (c:\eclipse)
  • tomcat 5.x if you want to use tomcat(c:\applications\Tomcat5.x)
  • jetty 5.1 if you want to use jetty(c:\applications\jetty5.1)

Following steps are common whether configuring for tomcat or jetty

  • create a new java project in eclipse.In project properties do add all the source code in the source path.
  • make the "destination path" as <root>/web/webapp/WEB-INF/classes in project properties.

  • create a new user library and add all jars under <root>/lib folder to it recursively.

  • Now the project should be compiling without errors and all class files should get generated under <root>/web/webapp/WEB-INF/classes.

Configuring in Tomcat

  • Either of the two eclipseplugins for tomcat need to be installed: "sysdeo" and "wtp tomcat plugin". We will cover Sysdeo plugin as it is easy to configure(wtp1.0 tomcat plugin enforces a predefined directory structure).
  • unzip sysdeo plugin into c:\eclipse\plugins directory and restart eclipse.
  • go to windows --> preferences --> Tomcat

  • select the tomcat version and enter the Tomcat home (c:\applications\Tomcat5.x). Click OK.
  • Click on the start tomcat icon in the eclipse toolbar to startup tomcat. ( make sure its running)
  • Now copy all jars under <root>/lib to c:\applications\Tomcat5.x\common\lib. directory structure under <root>\lib needs to be flattened up when copying to tamcat's common lib folder

  • create a new myproject.xml file in C:\applications\Tomcat5.x\conf\Catalina\localhost directory. Following needs to be entered:

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="${catalina.home}/../../workspace/myproject/web/webapp" path="/myproject">
  <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="localhost_myproject_log." suffix=".txt"

  • restart tomcat from eclipse by pressing the restart icon.
  • localhost:8080/myproject/index.faces shows welcome page. {OK}

Configuring in Jetty

  • Install JettyLauncher plugin from http://jettylauncher.sourceforge.net/updates and restart eclipse.

  • Right click on project --> Run as --> Run

  • Select "Jetty Web" on the left hand pane, and click new button at the bottom left hand corner.
  • In the screen that shows up on right hand pane, enter following:
    1. jetty home: c:\applications\jetty5.1

    2. webapp root dir: web/webapp

    3. contextname: myproject

    4. http host: localhost

  • Click on "Apply". Click "Run".
  • localhost:8080/myproject/index.faces shows welcome page. {OK}

hari_sujathan (last edited 2009-09-20 23:01:51 by localhost)