Using MyFaces with external and optional Modules
Using Tomahawk without an Internet connection (and with the Sun RI)
The tomahawk.jar file contains META-INF/faces-config.xml with a PUBLIC reference to web-facesconfig_1_1.dtd. This causes the DTD to be referenced from java.sun.com during application server startup (tested on Apache Tomcat 5.x but may apply to other servers as well). This problem manifests itself as follows (in this case, taken from the Apache Tomcat log file):
"javax.faces.FacesException: Can't parse configuration
file:jar:file:/<web-context-path>/WEB-INF/lib/tomahawk.jar!/META-INF/faces-config.xml"
A work-around for this problem is as follows:
Add META-INF/web-facesconfig_1_1.dtd to tomahawk.jar (obtain the file from
http://java.sun.com/dtd/web-facesconfig_1_1.dtd). Modify the header of faces-config.xml to reference the DTD from the same directory that contains faces-config.xml (META-INF) as follows:
<!DOCTYPE faces-config SYSTEM "web-facesconfig_1_1.dtd">
MyFaces with Sun JSF RI
Facelet support for tomahawk
Using MyFaces in Servlet Containers
JBoss
See
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces
Websphere 6
Orion 2.0.2
See Make it work with Orion application server
SunOne 7
Change the config security file so that MyFaces can delete its temporary files.
In {InstallDir}Sun/AppServer7/domains/domain1/{serverName}/config/server.policy
Change permission
java.io.FilePermission "<<ALL FILES>>", "read,write";
to
java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
SunOne 8.1
Change the config security file so that MyFaces can delete it's temporary files.
In {InstallDir}/SunOne8.1/domains/domain1/config/server.policy
Change permission
java.io.FilePermission "<<ALL FILES>>", "read,write";
to
java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
Prevent the sun reference implementation from being used
In your WEB-INF, create a sun-web.xml file containing
<?xml version="1.0" encoding="UTF-8"?>
<sun-web-app>
<class-loader delegate="false"/>
</sun-web-app>
That way, myfaces classes will be loaded instead of Sun RI ones.
And prevent MyFaces from loading the Sun RI context listener
By creating in your webapp a "fake" com.sun.faces.config.ConfigureListener that will be loaded BEFORE the sun RI one's.
Like that:
package com.sun.faces.config;
import javax.servlet.*;
/**
This class is here to prevent from using the real one from the sun reference implementation
/
public class ConfigureListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent servletContextEvent) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void contextDestroyed(ServletContextEvent servletContextEvent) {
//To change body of implemented methods use File | Settings | File Templates.
}
}
Apache Tomcat 4.x and 5.0.x
Apache Tomcat 4.x and 5.0.x should work with the MyFaces example war files.
All necessary library-files should be included in the war-file - except:
commons-el.jar
jsp-2.0.jar
You can download these files from
http://www.ibiblio.org/pub/packages/maven2/geronimo-spec/geronimo-spec-jsp/2.0-rc2/
http://www.ibiblio.org/maven/commons-el/jars/commons-el-1.0.jar
Apache Tomcat 5.5.x (except 5.5.9)
Apache Tomcat 5.5.x should work out of the box, all needed jars are supplied by the given MyFaces war files.
If you see a blank page on startup - the files jsp-2.0.jar and commons.el must be deleted, since Tomcat 5.5.x delivers those files out of the box and a library conflict is caused with the one given by the MyFaces war.
If you want to write your own tags you need the jsp-api-2.0.jar file in your compile classpath. If you use Maven2 you can exclude the jsp-api-2.0.jar from the war file by define a dependency like this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
The scope provided tells maven to exclude the jar file while packaging.
Apache Tomcat 5.5.9
Apache Tomcat 5.5.9 is somewhat special, due to some configuration problems in exactly this version (both lower and higher should be ok, and don't need this extra step).
BEA WebLogic 8.1
Add jsp-2.0.jar and servlet-api.jar (can be found in Tomcat 5.5.x share/lib) to classpath of server startup script (startWebLogic.sh/cmd) of WebLogic or include them in your war WEB-INF/lib
servlet-api.jar is required if your server has no internet connection. The reason is when MyFaces lib parse web.xml file, it assumes that web-app_2_3.dtd is accessible locally as javax/servlet/web-app_2_3.dtd or directly on
http://java.sun.com/dtd/web-app_2_3.dtd. WebLogic has not javax/servlet/web-app_2_3.dtd in it's lib
Steps for getting Facelets working with MyFaces on WebLogic:
Start with a working myfaces-1.1.2 webapp deployed on WebLogic Server 8.1sp5.
Copy the following three jar files from facelets-1.1.2 into your WEB-INF/lib directory: jsf-facelets.jar, el-api.jar, el-ri.jar.
Add this to your web.xml:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
Add this to your faces-config.xml:
<application>
<view-handler> com.sun.facelets.FaceletViewHandler </view-handler>
</application>
IMPORTANT: Clean out your compiled class files, delete your WebLogic server cache directory (.wlnotdelete), and rebuild.
If you want to use the tomahawk taglib, follow these instructions on the MyFaces wiki:
http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk
Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)
In order to deploy the simple.war from MyFaces 1.1.1 the following step were needed:
1. oc4j-config 1.1. application.xml
add lib-path pointing to tools.jar as described in oc4j-installation readme.txt
add <web-module id="simple" path="../../home/applications/simple"/>
1.2. http-web-site.xml
<web-app application="default" name="simple" root="/simple"/>
2. unpack the simple.war to home/applications/simple 3. webapp-changes
add the servlet-listener as described below ("Other Containers")
add jsp-2.0.jar and jstl.jar to the WEB-INF/lib directory
4. start oc4j
So far only the link to "Sample 1" fails with a 500 ... to be investigated.
Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)
In order to deploy my MyFaces (post-1.1.1 nightlies) and facelets (1.0) applications from the following step were needed:
Create an OC4J instance.
Log into the application server, and edit the .../j2ee/YOUROC4JINSTANCE/config/application.xml file for the instance to contain
<library path="../../../jlib/jsp-el-api.jar"/>
<library path="../../../jlib/commons-el.jar"/>
execute /ora/{...}/{...}/dcm/bin/dcmctl updateconfig -v -d
Deploy your application.ear
Note that to get facelets working, you must manually extract all facelets taglib.xml files from all facelet-enabled jar files (There are six taglib files in the jsf-facelets jar) and manually specify them from your web.xml file. Supposedly, this is not an issue for 10.1.3. Here's an example:
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/oc4j-hacks/jsf-core.taglib.xml;/WEB-INF/oc4j-hacks/jsf-html.taglib.xml;/WEB-INF/oc4j-hacks/jsf-ui.taglib.xml;/WEB-INF/oc4j-hacks/jstl-core.taglib.xml;/WEB-INF/oc4j-hacks/jstl-fn.taglib.xml</param-value>
<description>A semicolon (;) delimitted list of paths to Facelet tag libraries</description>
</context-param>
Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
In order to deploy the simple.war from MyFaces 1.1.1 the following step were needed:
1. oc4j-config 1.1. application.xml
add lib-path pointing to tools.jar as described in oc4j-installation readme.txt
add <web-module id="simple" path="../../home/applications/simple"/>
1.2. http-web-site.xml
<web-app application="default" name="simple" root="/simple"/>
2. unpack the simple.war to home/applications/simple 3. webapp-changes
add the servlet-listener as described below ("Other Containers")
4. start oc4j
So far only the link to "Sample 1" and "Sample 2" fails with a 500 ... to be investigated.
Oracle Application Server Containers for J2EE 10g (10.1.3.1.0)
In order to deploy my MyFaces core 1.1.4, a Tomahawk 1.1.5 nightly from 2006-08-18, and facelets 1.1.11 applications from the following step were needed:
Create an OC4J instance.
Deploy your application.ear
In Deployment step 3, edit deployment plan.
Choose "Edit Libraries"
Set path to "../../../../jlib/commons-el.jar"
Complete deployment. Note that you can save the deployment plan at this point and upload it with your ear file for future application deployments.
Other Containers
Some containers do not support registering listeners in tld files, such as Jetty 5.1.2 and earlier. For these containers, you must register the listener in the web.xml file, between the <filter-mapping> and <servlet> tags.
[...]
</filter-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
[...]
For Jetty 5.1.3rc0 and later, you need to uncomment the TagLibConfiguration in the jetty.xml file to enable registering listeners in tld files, or you can respecify it like this:
<Set name="WebApplicationConfigurationClassNames">
<Array type="java.lang.String">
<Item>org.mortbay.jetty.servlet.TagLibConfiguration</Item>
</Array>
</Set>
This option is enabled by default in Jetty 6.