Exercise 1: Introduction to Eclipse GlassFish Tools (30
minutes)
The goal of this exercise is to give you an
overview of the integration of the GlassFish Server within the Eclipse
IDE. You will also learn to inspect and configure Eclipse IDE
preferences which affect all registered GlassFish servers in Eclipse.
In this lesson we will learn to configure the
GlassFish v3 prelude server, access the administration console, change
the global server preferences, use the server help menu, connect to the
default derby database, register the GlassFish server, and use the
GlassFish server update center.
Background Information
Introduction to GlassFish Servers and GlassFish Eclipse
Intergration
GlassFish is an open source application server project
led by Sun Microsystems
for the Java EE platform. The commercial version is called
Sun GlassFish Enterprise Server. GlassFish is based on source
code donated by Sun and Oracle Corporation's TopLink persistence
system. It uses a derivative of Apache Tomcat as the servlet container
for serving Web content, with an added component called grizzly which
uses Java NIO for scalability and speed.
GlassFish Eclipse Integration
consists of the GlassFish Eclipse Plugin which is also an open source
project led by the Java Development Community. It allows IDE users to
develop, deploy and run their Java EE
applications by using the Eclipse IDE with GlassFish Servers v1, v2, v3
Prelude,
v3 Enterprise (promoted build), Saifin v1 and Sun Application Server
8.1 and
8.2 (J2EE SDK Reference Implementation).
Steps to Follow
- If the tools bundle is not already running, please start
it.
-
When Eclipse has started, close the Welcome page

- Click the Servers Tab. You should see Bundled GlassFish
v2.1 and v3 Prelude Servers appear

This tab shows the two GlassFish
server entries that have been pre-configured to work with Eclipse. Each
server has a popup menu for useful actions like "Start", "Debug",
"View Log File", "Get
Support...". Most of these actions are also available in the
toolbar.
-
Right-click the GlassFish v3 Prelude server node, then
choose the GlassFish Enterprise Server submenu.

The
"GlassFish Enterprise Server" popup menu has entries that allow for
quick access to the GlassFish Update Center UI, the registration page,
the Java EE Blog Aquarium Web site, the administration console page and
the log
viewer for
this application server. In order to access to the GlassFish Update
Center UI, the registration page and the administration
console page, you must start GlassFish server first.
Double-click on the Bundled GlassFish v3 Prelude node in the "Servers"
view to open the server editor. You can examine and fine tune server
parameters in this editor. For example, in the "Publishing"
section, you can configure whether the GlassFish server performs an
automatic redeployment of Web Application projects as soon as you save.
This can be a servlet change or a JSP change, or any class or web
artifact in this application. This feature is also called "Deploy on
Save" and for most web applications, this is very fast (less than a
second) with GlassFish v3 Prelude. By default for GlassFish v3 Prelude,
the "Publishing" is setup to "Automatic" with a 0 second interval
delay. If this is not the behavior you want, just select the "Never
publish automatically" option and save your settings.
Another setting in this editor is "Preserve Sessions Across
Redeployment". We'll learn more about that feature in
Exercise 2.
Let's start the GlassFish
v3 Prelude server by
clicking on the green arrow "Start" button (or popup menu
action). A
server log file will be opened in the Eclipse console.
You can use the "Display Selected Console" drop down menu to switch
between consoles in Eclipse's console tab. This is especially
useful when you have multiple servers running and would like to switch
between their respective server logs.
Once the server starts you should see the "Started" state and
"Synchonized" status for this server.
Step 3: GlassFish Server Global
Preferences
From the IDE Window menu, select the "Preferences" menu item to start
the
GlassFish server Preferences dialog.
Note: on Mac OS, you should select the "Preferences" menu from the
GlassFish menu
Select the "GlassFish Preferences" node to modify the
following flags:
- Enable GlassFish Plugin Log information in IDE log file
- This is more for the plugin debugging purpose than
anything
else. Turn on this option to see additional traces in the Eclipse log
file specific to the GlassFish Plugin. This option is OFF by default.
- Start the JavaDB database process when Starting GlassFish
Server
- GlassFish Server includes Java DB Database and this
option
allows you to start it automatically when the server is started. It is
very convenient to do when you work with JPA applications. The options
is ON by default.
- Start the GlassFish Enterprise Server in verbose mode
(Eclipse console can be used)
- Using this flag will send all the output log of the
Server
inside the Eclipse console as well. This options is OFF by default as
there is a GlassFish specific log view.
- Enable colored rendering in the GlassFish Log Viewer
- For color blind people, you can turn this option OFF.
Otherwise, INFO level messages will be black, WARNING messages will be
yellow, SEVERE messages will be red, and multiple line entries will be
Italic.
To open the administration console, you can either choose "View Admin
Console" from the GlassFish Enterprise Server popup menu on the
GlassFish server node or click the GlassFish icon in the toolbar.
Remember that the server must be running to use the administration
console.
The GlassFish administration console will be shown in the Eclipse
embedded
browser. For GlassFish v2.1 or v3 enterprise server, you need to
provide login userName and password.
- Click the Data Source Explorer tab
2. Right-click "Sample JavaDB Database" then select
"Connect"
menu.
3. Expand the "sun-appserv-samples" node to view the Schemas,
then expand the "APP" node to view the sample database. If you
expand the "Tables" node, you will see the sample tables in our
database. We will use these tables in Exercise
2.

6. Accessing the
GlassFish v3
Prelude Update Center from Eclipse
-
From the Servers tab, you can either choose
"Registering your
GlassFish Server" from the GlassFish Enterprise Server popup menu on
the GlassFish server node or click the "Bundle GlassFish v3
Prelude" icon in the toolbar.
-
When the Product Registration page comes up, fill in your
information then click the "Register" button. The first time you launch
the GlassFish Tools Bundle for Eclipse, you will be asked to
register. If you did not do so, you can always register by
accessing this menu here.

Summary
In this exercise, we covered an overview of the GlassFish
Server Usage
menu, opening the GlassFish Server Configuration Editor, launching
Administration
Console, viewing Server Log, changing Server Global Preferences,
connecting to the default JavaDB, and accessing the Update Center.
In the next exercise you will learn to create some basic Java EE
projects using the GlassFish v3 Prelude application server.
Back to top
Next
exercise