Posted by cayhorstmann
on February 2, 2009 at 3:27 PM PST
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. In this blog, I describe the recent simplifications, show how to set up Glassfish, give a sample app, and explain why we haven't quite reached 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
Here is a laundry list of recent simplifications.
The WAR file has the structure
web pages (.xhtml)
stateless session beans
There are three cookie-cutter XML files that you never need to touch. In
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.
- Add the glassfish-v3-prelude-version/glassfish/bin directory to
- Run glassfish-v3-prelude-version/updatetool/updatetool. Add the
Glassfish EJB container. Install any available updates.
- Check the version of the JSF implementation in the updatetool. If it
is < 2.0, delete it and go back to the list of available modules. You should get a 2.0 module that you can install. You need version 126.96.36.199 or above.
- Start the server:
- Download and unzip
href="http://horstmann.com/elvis/SimpleQuiz.zip">this test application.
build.properties and set the path of your Glassfish
ant. Point your browser to
- You can use the EE version of Netbeans 6.5 out of the box. With the EE
version of Eclipse 3.4, install the
Glassfish adapter . When you import the sample project into Eclipse,
make a “Dynamic web project”, set the source path to
src), the web path to
WebContent), and uncheck “Generate
deployment descriptor” . Both Netbeans and Eclipse do a beautiful job
Overall, I was very
happy. This is a huge step forward from five years ago, when Bruce Tate refused
Elephant again .
Have we reached Nirvana? Not quite. Here are some remaining hassles:
- I hate writing (and reading) all those getters and setters. Did I ever
mention that Java
support for properties?
- For a simple app, it is a nuisance to separate managed beans and session
beans. Web beans, erm,
Contexts and Dependency Injection, should solve that, but I didn't have
the courage to throw that into the mix. Next semester :-)
- Error reporting has become better, in no small part thanks to facelets.
But I still get the
trace from hell more often than I'd like.