Tuesday, November 8, 2011

Setting up JSF 2.0 and EL 2.2 on Glassfish v2

I am migrating our JSF 1.1 application to JSF 2. Since we are still running Glassfish 2.1.1, I can't use the latest version of JSF (2.1.3), which targets Servlet 3.0 containers like Glassfish v3. So I settled with JSF 2.0. One of the nice features of JSF 2.0 is the build-in page templating support, which is a big help to clean up those messy jsp files.

While setting up the templates, I found that we need to pass parameters to methods in the jsf/xhtml file. But this is NOT supported by default in Glassfish 2.1.1. Comes EL 2.2 for the rescue.

It is kind of easy to set up JSF 2.0 and EL 2.2 on Glassfish v2:

1) Add el-impl-2.2.jar in your project pom.xml (assuming you use maven), which will install two jar files (el-impl-2.2.jar and el-api-2.2.jar) in your WEB-INF/lib after build:

    <dependency>
      <groupId>org.glassfish.web</groupId>
      <artifactId>el-impl</artifactId>
      <version>2.2</version>
    </dependency>

2) Copy el-impl-2.2.jar and el-api-2.2.jar to %Glassfish_Home%/lib/

3) Download jsf 2.0 from http://javaserverfaces.java.net/, then copy jsf-impl.jar and jsf-api.jar to %Glassfish_Home%/lib/

4) Add "classpath prefix" in glassfish domain configuration file domain.xml (or you can use the Admin console: Application Server -> JVM Settings -> Path Settings -> Classpath Prefix):

<java-config classpath-prefix="${com.sun.aas.installRoot}/lib/jsf-api.jar${path.separator}${com.sun.aas.installRoot}/lib/el-api-2.2.jar"
...


You are all set to roll!

No comments:

Post a Comment