Skip to main content

TOTD #47: Getting Started with Mojarra 2.0 nightly on GlassFish v2

Posted by arungupta on October 14, 2008 at 5:54 AM PDT



Java Server Faces 2.0 href="http://jcp.org/aboutJava/communityprocess/edr/jsr314/index2.html">specification
(JSR 314,
EDR2) and implementation
(soon to be EDR2) are brewing. This blog shows how to get started with href="https://javaserverfaces.dev.java.net/">Mojarra
- Sun's implementation of JSF.



GlassFish v2 comes bundled with Mojarra 1.2_04 which allows you to
deploy a JSF 1.2 application. This blog explains how you can update
GlassFish v2 to use Mojarra 2.0 nightly. And then it deploys a simple
JSF 1.2-based application on this updated GlassFish instance, there by
showing that your existing JSF 1.2 apps will continue to work with
Mojarra 2.0-enabled GlassFish. This is an important step because it
ensures no regression, unless it was a compatibility fix :)

  1. Re-create a simple JSF 1.2 application as described in href="http://blogs.sun.com/arungupta/entry/totd_42_hello_javaserver_faces">TOTD
    #42, href="http://blogs.sun.com/arungupta/entry/totd_45_ajaxifying_java_server">TOTD
    #45 and href="http://blogs.sun.com/arungupta/entry/totd_46_facelets_with_java">TOTD
    #46. This application allows to create a list of cities and
    store them in a backend database. It uses href="https://jsf-extensions.dev.java.net/">JSF Extensions
    to show suggestions, using Ajax, based upon the cities already entered
    and also uses Facelets
    as the view technology. Alternatively you can use any pre-existing JSF
    1.2 application.
  2. Download Mojarra 2.0 href="https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=9814&expandFolder=9814&folderID=1703">latest
    nightly.
  3. Follow href="https://javaserverfaces.dev.java.net/nonav/rlnotes/2.0.0/releasenotes.html">Release
    Notes to install the binary, the steps are summarized here
    for convenience (GlassFish installed in GF_HOME):
    1. Backup "GF_HOME/lib/jsf-impl.jar".
    2. Copy the new "jsf-api" and "jsf-impl" JARs from the
      unzipped Mojarra distribution to "GF_HOME/lib".
    3. Edit
      "GF_HOME/domains/<domain-name>/config/domain.xml" and add
      (or update the existing "classpath-prefix")
      'classpath-prefix="${com.sun.aas.installRoot}/lib/jsf-api.jar" in the
      java-config element.
    4. Restart your server.
  4. Deploy the application on Mojarra 2.0-enabled GlassFish,
    that's it!

The application is accessible at
"http://localhost:8080/Cities/faces/welcome.xhtml". Some of the screen
captures are shown below.



If only "S" is entered in the city name, then the following output is
shown:



src="http://blogs.sun.com/arungupta/resource/images/mojarra2-cities-jsf12-s.png">



Now with "San" ...



src="http://blogs.sun.com/arungupta/resource/images/mojarra2-cities-jsf12-san.png">



And another one with "De" ...



src="http://blogs.sun.com/arungupta/resource/images/mojarra2-cities-jsf12-de.png">



With JSF 2.0, Ajax capabilities and Facelets are now part of the
specification and have already been integrated in Mojarra. A follow up
blog entry will show how to use that functionality.




The downloaded Mojarra bundle has some samples (in "samples" folder) to
get you started, have a look at them as well!



File JSF related bugs href="https://javaserverfaces.dev.java.net/issues/enter_bug.cgi?issue_type=DEFECT">here
using "2.0.0 EDR1" version and ask your questions on href="mailto:webtier@glassfish.dev.java.net">webtier@glassfish.dev.java.net.



Please leave suggestions on other TOTD ( style="font-weight: bold;">Tip style="font-weight: bold;">Of style="font-weight: bold;">The style="font-weight: bold;">Day) that
you'd like to see.
A complete archive of all tips is available href="http://blogs.sun.com/arungupta/tags/totd">here.




Technorati: totd
javaserverfaces
glassfish
mojarra
netbeans

Related Topics >>

Comments

agoncal, GlassFish v3 prelude (scheduled for later this month) is Java EE5 compliant and so will Mojarra 1.2.0_10 is still the default implementation. Mojarra 2.0 will soon be available on v3 Update Center and later become the default implementation in v3 as well. The timelines of when the actual integration will happen are still being worked upon. When Mojarra 2.0 is available on v3 UC and then made the default in v3, you'll hear it on this blog :)

Do you know if Mojarra is the default JSF implementation of GlassFish V3 ?