Posts Tagged ‘Glassfish’

GlassFish integration with NetBeans, Eclipse and JDeveloper

9 August 2008

This is how GlassFish integrates with NetBeans 6.1, Eclipse 3.4 (Ganymede) and JDeveloper 11g.

NetBeans

NetBeans 6.1 provides out-of-the box integration as it is bundled with GlassFish.

Just keep the default setting “GlassFish V2 UR2″ enabled during installation process.

In this way GlassFish is automatically installed, configured and ready-to-use: simply press “Run” on any web project!

However, if you would like to declare another installation of GlassFish go to Tools → Servers → Add Server…

Select the proper version, specify the name and click “Next.

Provide the installation path of GlassFish through the “Browse” button and click “Next” to configure the password or “Finish” to complete.

That’s it!

Let’s create a simple web application to test it. Go to File → New Project… → Web → Web Application → Next → Specify the Project Name → Finish

The project should appear on the Projects tab. Edit the code of index.jsp and change <h2>Hello World!</h2> to <h2>Hello World from GlassFish!</h2>

Now simply right-click on the project and select “Run”!

Eclipse

If you are behind a proxy make sure you have properly configured the network settings for HTTPs also. Window → Preferences → General → Network Connections and make sure the option “Use this proxy server for SSL” is checked → Apply → OK → restart Eclipse.

Open the Servers view: Window → Show View → Other… → Server → Servers

On the Servers tab right-click → New → Server

Click on the “Download additional server adapters” link.

Click on the GlassFish Java EE Server option and press “Next”.

Afte reading and accepting the CDDL licence press “Finish” and OK at the prompt message. After a while Eclipse will restart.

Now go the Servers tab right-click → New → Server and select “GlassFish”.

Note: The plugin for brand new GlassFish v3 Technology Preview 2 is already available!

Select the version of GlassFish you have installed and press “Next”.

Provide the installation directory of GlassFish and click “Next”.

That’s it!

JDeveloper

JDeveloper has a really handy feature: deploy-on-demand.

Let’s assume we want to deploy a web application. In the Application Navigator right-click on the project → New… → General → Deployment Profiles

Select war and click “Next”.

After specifying the name, for example “wicket”, provide the hot-deploy directory of GlassFish through the “Browse” button.

That’s it!

To deploy the application simply right-click on the project → Deploy → wicket → to WAR file.

GlassFish for the developer

5 August 2008

GlassFish is an open-source Java EE 5 application server of enterprise quality.

In this short article we’ll manually setup and go through the basics of GlassFish.

Step 1. Download

To download GlassFish go to glassfish community → Download → Scroll down the page → Binary builds → Windows Platform → glassfish-installer-v2ur2-b04-windows.jar

Step 2. Install

To install GlassFish run the jar file as follows

The -Xmx250m flag simply provides more memory to this operation.

A window appears with the CDDL licence agreement.

The installation process ends with a “installation complete” message on the command-prompt. Note that a folder glassfish is created.

Step 3. Setup

To setup GlassFish enter the glassfish folder and run the setup.xml script with ant.

This process should complete with a “BUILD SUCCESSFUL” message!

Step 4. Start

To start GlassFish use the powerful asadmin tool.

To verify check http://localhost:8080 where we can deploy our applications.

Admin console

Once the server has started, a full-featured administrator console is available at http://localhost:4848.

Use admin as user and adminadmin as password.

The most valuable link for a developer is Home → documentation → Developer’s Guide.

At the left it’s the Application tree where we can see and deploy Enterprise Applications (.ear), Web Applications (.war) and EJB Modules (.jar).

Deploy an application

Here’s two ways to deploy a simple web application in GlassFish:

1. Accessing the hot-deploy folder

Simply put the application file in the autodeploy folder of the current domain, for example in C:\glassfish\domains\domain1\autodeploy.

That’s it!

Note: The JBOSS users should not be suprised at all :)

That’s the same folder we should specify to tools like JDeveloper that handle packaging and deploying for us.

2. Using the admin console

Go to Applications → Web Applications → Deploy… → Location → Browse… → provide the path to the .war file → OK

At a glance

Let’s take a look inside the installation folder, for example inside C:/glassfish.

We see that GlassFish is bundled with JavaDB; a really cool database, written 100% in Java, used more than 10 years in production!

The bin folder has some useful tools, so it’s a good idea to put it in the PATH enviroment variable.

The domains folder contains independent server configurations. By default domain1 is available.

Inside a domain, the most important folders are autodeploy, where the applications are deployed, and config where various configuration takes place.

Summary

I agree with Marc Fleury that GlassFish looks the only application server capable of competing JBoss in the market. It’s slightly more tedious to install (GlassFish: 2 commands, JBoss: just unzip a file). However it’s as easy to use (hot-deploy) and it has a beautiful administrator console GUI (by the way it’s JSF).

All the action about GlassFish is at the glassfish community.

Also, Sun is offering a free introductory online course – for details see here.

Finally, for out-of-the-box development experience with GlassFish you may use the NetBeans IDE.

Thanks.

Free Sun Training Courses

9 June 2008

Sun is currently offering these online courses for free.

OpenSolaris Technical Essentials Guide (WS-1000-OS)
http://www.sun.com/training/catalog/courses/WS-1000-OS.xml

Glassfish Application Server: Introduction (WMT-SAS-1536)
http://www.sun.com/training/glassfish_login.html

Thank you.