This post continues from we were after the posts:
GlassFish Server – Installing the Tools in Eclipse
After the setup of Eclipse and the JDK, within Eclipse open the marketplace:
And search “glassfish”. Those are the results you should see coming up:
You will have to click on the Install button for the GlassFish Tools for Juno (see picture above).
A confirmation window will popup with the options selected. I’ll leave all of them enabled and click Next:
Then of course accept the agreement and click Finish:
Then be patient while the installation takes place…
At the end you will be prompted to restart eclipse. Do it.
Once restarted, let’s add a new GlassFish Server.
GlassFish Server – Adding a reference in Eclipse
In order to do so switch to the Server tab (visible in the lower area of the IDE):
If you can’t see this tab for any obscure reason, you can still access to ti through the menu: Window->Show View->Servers:
If you don’t see this option neither, then click on the “Other…” option in the same menu list ( Window->Show View->Other…) and in the search window type “servers” or look in the Server section. Select the “Servers” component and click OK:
In this window you should see a link to “new server wizard…” if you don’t have any server configured:
Otherwise (or anyway in any case) you can right-click in the server window and select New->Server:
The server wizard window should come up.
Select one of the GlassFish options. I’ll select the version 3.1.2. Click Next once selected:
In the next window you will have to provide eclipse with the information about the location of your glassfish installation (where you extracted it) and the JRE to use.
By default it will suggest the default ones, but I selected the jdk7 this time.
Click Next once finished. Note that the folder must be the glassfish one and not the parent folder (see picture). Eclipse will help you if you select the wrong folder anyway.
Nothing much left to do here, except inserting the correct admin name and password and click Finish.
Note that if you click Next, you will have the possibility to associate immediately some projects with this server, but I don’t have any project that I want to associate in this moment.
At this point the server should be visible in the Servers Tab:
GlassFish Server – Starting it in Eclipse
If you double click on it you will see a nice window that will show you some of the options you have access to:
Another nice thing we can explore at this point is the server admin panel as well.
In order to do so we need first to start the server.
One way of doing this is selecting our glassfish server in the servers tab, and clicking on the big green play button on the right (or pressing Ctrl + Alt + R as visible in the tooltip):
An alternative way is rigth-click on the server itself and selecting the Start from here:
The Console should get focus automatically and if everything is as it should, then you should see some nice logs to communicate that everything worked as expected.
If not, and you see something like this:
Or even this:
Then open again the option window (double click on glassfish) and modify one of the connection options.
Untick the “Use Anonymous Connection for Admin Commands” option and of course make sure that the username and password are the correct one.
Save the change (or simply close the window and save when prompted) and retry to start the server.
Wait of course for the indicator in the lower right corner to complete:
And this time if this time everything goes fine the servers tab should now show that our glassfish instance is started (and synchronized):
GlassFish Server – Interacting with it with the Admin Console
A nice thing to explore now is the glassfish admin console (on the running server).
You can do this directly in eclipse, right-clicking on the glassfish server and navigating to the option GlassFish->View Admin Console:
A new window should open in the eclipse IDE and should connect to the glassfish home url (localhost:4848 in my case):
From here, inserting the correct credentials and logging in, you will have access to your admin console in all ts wonder!
That’s it for now. You can enjoy to explore the numerous options here and I’ll continue the tutorial with the creation of a servlet to run on this (and other) servers in another post.
Thanks for tuning and see you next time!