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


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

  1. Hey Maxi,

    Thanks for your post. Do you have any idea as to how to configure log4j for icefaces applications. Basically i can get icefaces working now but i’m not sure what is happening under the hood.


  2. Goutham123, you are welcome.
    I never really use log4j in production. Did you have a look at their doc
    Basically use it like this, create a properties file for log4j, include the log4j jar into your project. Load the properties file in your code, create a Logger object with it. Then write log using like logger.debug();
    I have shifted to C# for a while now, so Hope this help.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s