David is a systems architect who has been developing software professionally since 1991. He started programming in Java way back with Java 1.0 developing desktop applications and applets. Since 2001 he has been developing enterprise applications using both Java standards and open source solutions. David is the author of "Building SOA-Based Composite Applications using NetBeans 6" and "Seam 2.x Web Development". David is a DZone MVB and is not an employee of DZone and has posted 22 posts at DZone. You can read more from them at their website. View Full User Profile

Using GlassFish from Eclipse

12.22.2011
| 19891 views |
  • submit to reddit

When I think of developing apps using GlassFish, I usually think of using NetBeans for the development. As you'd expect however, Oracle provides some good tooling to allow you to develop against GlassFish from within Eclipse - even to the point of installing the application server directly from within Eclipse.  So, how is this done?

Installing GlassFish Server Tools

Contrary to what you'd expect, to install GlassFish tooling, you don't use the Eclipse Marketplace for installation.  To install, right click within the "Servers" pane and select "New | Server" to display the "Define a New Server" dialog. On this dialog, select "Download additional server adaptors" and in the resulting dialog select "Oracle GlassFish Server Tools".


After accepting the licence conditions, the GlassFish Server tools will be downloaded upon which you'll need to restart Eclipse to complete the installation.

Defining a GlassFish Instance

After a restart, opening the "Define a New Server" dialog will show that GlassFish support has been added.


Choose the GlassFish server you wish to use and press the "Next" button.  On the resulting dialog, you can choose to locate an existing copy of GlassFish, or install an new instance via the "Install Server" button if you don't already have GlassFish installed.


One point to note here is that, if you install a new instance of GlassFish, you may then need to browse through the install folder to locate the "glassfish" folder within.  You will see that this is necessary because the "Next>" button will be disabled as you've installed an instance of GlassFish, but not correctly identified its location to Eclipse.

When you've selected (and installed if necessary) a GlassFish instance, complete the wizard to define the admninistrator credentials of the server.

GlassFish Tools

After creating a GlassFish server instance in Eclipse, you can develop and test Java EE 6 applications against it.  The GlassFish tools provides additional support to assist in this.  For example, right clicking on the server in the "Servers" tab allows you to manage the server or get additional information or support.


New wizards are also installed into Eclipse to assist when creating GlassFish facets such as JMS or JDBC resources as shown below.  These wizards are available on the standard "File | New | Other" dialog under the "GlassFish" folder.

 

From http://www.davidsalter.com/2011/12/using-glassfish-from-eclipse.html

Published at DZone with permission of David Salter, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Ash Mughal replied on Thu, 2011/12/22 - 10:05am

Hi David. Nice efforts and very good article.

Can you please inlcude more on glass fish trouble shooting with eclipse. 

I am a java programmer and love to develop web based applications. I have worked with all servers like tomcat, jboss and others. Also some time its hard to fix issues with these servers.

David Salter replied on Sat, 2011/12/24 - 5:56am in response to: Ash Mughal

Hi Ash, I'm glad you enjoyed the article. What sort of problems are you having with Eclipse? Are they EE issues or GlassFish issues?

Carla Brian replied on Wed, 2012/05/09 - 9:03am

Thank for sharing this one. I am new to this also. I still have to download more tutorials for this. Thanks for sharing this one. - Instant Tax Solutions Reviews

Theresa Stewart replied on Thu, 2013/04/04 - 10:23pm in response to: David Salter


Hi, David.

Thank you for this tutorial.  I had to piece things together on my own, and this would have made it go much quicker.

I do now have a Deployed Application showing on my GlassFish 3.1.2 server (which started successfully).  Now I am at the point in the tutorial where I am trying to use the deployed application, and having a difficult time of it.  I have launched my Admin Console, and I have created an External Resource in order to create a JNDI Name, and I access it in my test application using:
Context ic = new InitialContext();

Object o = ic.lookup( "<this is where I should be able to put in my JNDI Name>" );

<etc.>

However, I see javax.naming.NamingException:  Lookup failed for <this is where I should be able to put in my JNDI Name>" ....

I suspect my question is very basic, but can't seem to find any other site that comes close to answering my question.  Perhaps you can point me to a source that can answer this basic question of how to connect the test application to the bean?

Thank you,

Theresa

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.