Saturday, 20 June 2009

Using Eclipse Galileo to develop JSF applications on Glassfish (OS X)

These are rough notes for getting Eclipse Galileo (3.5) and GlassFish 3 Prelude to work together for deploying and developing JSF applications. I've encountered a few issues still with both of these things but am pleased to say that once you're up and running, you can be very productive, so it's worth taking the steps to get the environment set up.

If you're happy using a build of Ganymede (3.4), I'd recommend installing the Glassfish bundle instead: http://download.java.net/glassfish/eclipse/


I'm working on the premise that the user has the JDK1.6 already installed in OSX - to confirm this, you can check for the presence of this folder: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

I'm also writing these notes before Galileo is released (should be released 4 days from time of writing)

Here are the steps required:

1. Go to http://www.eclipse.org/downloads/ and select the "Development Builds" tab. Download the Eclipse IDE for Java EE Developers (188 MB) and I'd recommend getting the one for Mac OS X (Cocoa).

2. Download Glassfish Prelude from here: http://download.java.net/glassfish/v3-preview/release/glassfish-v3-web-preview-unix.sh. You'll probably need to run it from the command line (chmod a+x glassfish-v3-web-preview-unix.sh followed by ./glassfish-v3-web-preview-unix.sh)

3. Once the glassfish installer has completed, start Eclipse and confirm that you have a Java 1.6 JDK registered. To do this, go to Eclipse > Preferences > Java > Installed JREs. If you can't see anything that says something like "JVM 1.6.0" select "Add..." and choose MacOS X VM then Next.

The JRE Home should be /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

And the choice of name is up to you.

4. Next you will need to install the GlassFish adapter. Go to Help > Install new Software. Select "Add" and add this location: https://ajax.dev.java.net/eclipse. Once that's done, you should see an option for "Glassfish Java EE5 and Java EE6 support". Select that and Next or Finish. Eclipse will require a restart.

5. To add the GlassFish server, first ensure you're in the Java EE perspective and locate the tab marked "Servers", right click, select New > Server. Open out the GlassFish options and select GlassFish v3 Prelude.

For the JRE, make sure you're choosing the 1.6.0 JVM and your application directory should be something like: /Users/%yourusername%/glassfishv3/glassfish. I had to select Install Server too.

6. Once that's completed, you can highlight the listed server and hit the green start button. A brief visit to localhost:8080 should confirm this.

I've posted up a simple jsf example project here: http://jsf-examples.googlecode.com/files/simple-jsf-example.zip if you'd like to test your GlassFish installation, import it into eclipse and right-click and Run as > Run on Server and select your recently created instance of GlassFish v3 Prelude

No comments:

Blog Archive