Icefaces Application on Tomcat 6 using Netbeans

Similar to the portlet development but simpler.

download latest icefaces 1.7 RC1

pack these in library manager as Icefaces 1.7 library









Create a web application project and use JavaServerFace framework.

include Icefaces 1.7 library that we create.

Add these to your web.xml

        <servlet-name>Persistent Faces Servlet</servlet-name>
        <load-on-startup> 1 </load-on-startup>
        <servlet-name>Blocking Servlet</servlet-name>
        <load-on-startup> 1 </load-on-startup>

        <servlet-name>Persistent Faces Servlet</servlet-name>
        <servlet-name>Persistent Faces Servlet</servlet-name>
        <servlet-name>Blocking Servlet</servlet-name>

Add a jspx to you project, if you put that under Web pages/jspx/foo.jspx

You will need to use it by http://localhost:8080/projectName/jspx/foo.iface

you are all set.



Develop JSF1.2 with Netbeans 5.5.1 running on Tomcat 6 with Mysql backend

My Environment

JSF 1.2

Netbeans 5.5.1

Tomcat 6

Mysql 5

Prepare Tomcat 6

Download and unpack Tomcat 6.

Run: [tomcat6]\bin\startup.bat in windows

Shutdowm: [tomcat6]\bin\shutdown.bat in windows

Change port: [tomcat6]\apache-tomcat-6.0.16\conf\server.xml

Add user: [tomcat6]\apache-tomcat-6.0.16\conf\tomcat-user.xml

<role rolename="manager"/> <user username="tomcat" password="s3cret" roles="manager"/>

Open server manager in Netbeans-> Add Server, choose Tomcat 5.5(I don’t see Tomcat 6 and don’t know how to add it). Catalina Home means where you unpack Tomcat 6. username/password is the manager username/password we set previously.

You can run and deploy project using Tomcat 6 by now.

Prepare Mysql

Download and run it as a service from Mysq which will be trivial to teach.

Copy JDB-connecter for Mysql under [tomcat6]\lib

Add the following setting in your context

<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
removeAbandoned="true" emoveAbandonedTimeout="60"/>

Context for tomcat 6 can be in the following ways!

  • in the $CATALINA_HOME/conf/context.xml file: the Context element information will be loaded by all webapps
  • in the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host
  • in individual files (with a “.xml” extension) in the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml extension) will be used as the context path. Multi-level context paths may be defined using #, e.g. context#path.xml. The default web application may be defined by using a file called ROOT.xml.
  • if the previous file was not found for this application, in an individual file at /META-INF/context.xml inside the application files
  • inside a Host element in the main conf/server.xml

I prefer the /META-INF/context.xml in your project under <web-app>

Put this in your web.xml in your project:

<description>MySQL Test App</description>
<description>DB Connection</description> 

***注意:如果你在Netbeans5.5裡面run你的project會有問題,因為netbeans5.5自動include mysql connector,會跟[tomcat 6]\lib裡面的相沖

You are now ready to use Myql in your project.

Prepare JSF

JSF1.2 need Servlet 2.5 and JSP 2.1 which tomcat 6 can provide.

Download JSF and JSTL

Create Web project and Add JSF framework in project properties.

This is the same as doing JSF setting in web.xml, netbeans user don’t need to do this by hand.

<!-- Faces Servlet -->
<servlet-name>Faces Servlet</servlet-name>
<load-on-startup> 1 </load-on-startup>

<!-- Faces Servlet Mapping -->
<servlet-name>Faces Servlet</servlet-name>

Add JSF managed bean by right clicking in project navigator.

Which will automatically add setting in faces-config.xml by Netbeans,

you can do it yourself by adding the following in faces-config.xml:


Replace library with those we download previously : jsf-api.jar and jsf-impl.jar for JSF ;standard.jar and jstl.jar for JSTL

JSF file can be .jsf or .jsp, I don’t know how to create .jsf. so I just use .jsp instead.

You are all set. Have Fun