Towards Java EE Nirvana

Java EE 6 makes it pretty straightforward to crunch out a basic web + database application. This semester, my software engineering class is building web apps, and I decided it is simpler to have them use JSF + JPA in Glassfish v3 rather than some technology that seems easy at first and then lets them down.

Here is a laundry list of recent simplifications.

The WAR file has the structure

web pages (.xhtml)
WEB-INF/
  web.xml
  faces-config.xml
  classes/
    managed beans
    stateless session beans
    entity beans
    META-INF/
      persistence.xml

There are three cookie-cutter XML files that you never need to touch. In particular, faces-config.xml is empty! The rest is XHTML and Java.

Unfortunately, setting up your tools is a bit of trouble because everything is right now a moving target. Here are the steps.

  1. Install Glassfish v3 Prelude
  2. Add the glassfish-v3-prelude-version/glassfish/bin directory to your PATH
  3. Run glassfish-v3-prelude-version/updatetool/updatetool. Add the Glassfish EJB container. Install any available updates.
  4. Check the version of the JSF 2.0 implementation in the updatetool. If it is ≤ 2.0.0.8, download the JSF 2.0 Nightly build; pick mojarra-2.0.0-SNAPSHOT-binary.zip and replace glassfish-v3-prelude-version/modules/jsf-api.jar and glassfish-v3-prelude-version/modules/web/jsf-impl.jar with the versions in that zip file.
  5. Start the server:
    asadmin start-database
    asadmin start-domain
  6. Download and unzip this test application. Edit build.properties and set the path of your Glassfish installation. Run ant. Point your browser to http://localhost:8080/SimpleQuiz

  7. You can use the EE version of Netbeans 6.5 out of the box. With the EE version of Eclipse 3.4, install the Eclipse Glassfish adapter . When you import the sample project into Eclipse, make a “Dynamic web project”, set the source path to src/java (not src), the web path to web (not WebContent), and uncheck “Generate deployment descriptor” . Both Netbeans and Eclipse do a beautiful job with hotswapping.

Overall, I was very happy. This is a huge step forward from five years ago, when Bruce Tate refused to eat Elephant again.

Have we reached Nirvana? Not quite. Here are some remaining hassles: