Plug-ins add features to Eclipse
Many developers are attracted to the Eclipse platform because its core capability can be extended by additional features. Eclipse provides a well-defined mechanism for this extension ability. Every aspect of Eclipse is contained in a plug-in, and plug-ins can dynamically extend other plug-ins, as well as define extension points that allow other plug-ins to extend them. The plug-in itself defines the type of function that can be provided via these extensions, and not the basic Eclipse infrastructure. For example, the extension can be as simple as a new entry in a pop-up menu, or as comprehensive as a completely new type of project, or a series of editors and views.
Base Eclipse support includes the Java Development Tool, or JDT, which provides a complete Java development environment. However, a new Eclipse tools project known as the Web Tools Platform (WTP) was announced last year, with a goal of providing the base capabilities required to develop J2EE™ Web applications. IBM has donated a significant amount of code to this project, and several other companies are collaborating with its ongoing development. The first release of the WTP is scheduled to be available on July 29, 2005.
Although the WTP project does not provide advanced development capabilities or ease-of-use features that are available in modern commercial integrated development environments (such as IBM Rational® Application Developer), it does provide a common open source base that defines necessary underlying structures. This base includes the definition and structure of the base project types, the basic editors that can be used to modify the various artifacts, and the support for defining and interacting with application servers. (You can find more information about Eclipse and the Web Tools Platform in the Resources section later in this article).
The Web Tools Platform and Apache Geronimo
The WTP project currently provides support for deploying projects to several open source and Web application servers, including the Apache Tomcat servlet container. A new open source project being developed -- Apache Geronimo -- provides a complete application server, including not just the servlet container, but also support for messaging, a database including JDBC connectors, and a portal framework. A new plug-in for WTP is being developed and is available on the eclipse.org Web site; it provides integration between WTP and Apache Geronimo (see Resources for a link to the plug-in). This plug-in allows you to use WTP as a very basic development environment for creating, deploying, and debugging Geronimo applications.
Deploy and use the base WTP project
At the time of this writing, the M4 milestone of the WTP project has just been released, and is available for download (see Resources). As described in the eclipse.org overview of the project, a number of prerequisites are required to install the WTP, which you must download and install before you can install the WTP. These prerequisities include the base Eclipse driver and additional drivers for GEF, EMF, and the Java EMF model. Links for the correct version of all these files are available from eclipse.org (see Resources) .
Download and unzip the base WTP project and the Geronimo plug-in
After you have downloaded the prereqs and unzipped the base WTP project and the latest WTP milestone build, you can download the Geronimo plug-in. The plug-in will be available in future WTP builds, but for use with the WTP M4 driver, you can download the plug-in by itself (see Resources). Unzip this plug-in into the following location: eclipse/plugins/org.eclipse.jst.server.geronimo.core_1.0.0.
The final step in the preparation process is to start Eclipse for the first time using the –clean option, to ensure the new plug-in is recognized. Once you start Eclipse, you'll see a startup screen like this:
Figure 1. The Eclipse startup screen
After starting Eclipse, the next step is to define the Geronimo server within the environment. Select File > New file wizard to create a new server. On the second page of this wizard, when prompted to select the server type, choose Apache Geronimo, as shown in Figure 2.
Figure 2. Define a new server
You’ll next be prompted for the installed location of the Apache server and the root directory used to locate the jars necessary for the development project’s classpath. The next page allows you to define additional information about the server; of particular importance is the administration user ID and password that you specified when you installed Geronimo. On the final page of the wizard, you can add existing projects to the server. Because you have not yet created any projects, just select Finish.
You have now provided enough information to start and stop the Geronimo server from within Eclipse. To see the server status, the easiest way is to go to the J2EE perspective; select the Window > Open Perspective > Other menu, and then select the J2EE perspective from the dialog shown. In this perspective, a Servers view is available in the bottom right of the screen, as shown in Figure 3:
Figure 3. The Servers view in the J2EE perspective
Select the Geronimo server shown in this view and choose Start from the pop-up menu. This starts the server and displays the output in the console window. You can also start the server in debug mode from this same view.
Create project and module definitions
Now that the server is running, the next step is to create an application to run on it. The WTP support allows you to have multiple Web modules within a single Eclipse project -- therefore, you now need to create both the project and module definitions. From the J2EE navigator, select the Dynamic Web Projects icon, and from that pop-up menu choose Create a new J2EE Web module. On the resulting wizard, you can select an existing project or create a new project to contain the Web module. Because this is an empty workspace, select New to create a new project. In the New project dialog, enter the project name and select Geronimo as the target server. After you finish this wizard, enter the name of the new Web module to be created. After you finish the new module wizard, you will see the newly created project and module under the Dynamic Web projects icon, as shown in Figure 4.
Figure 4. The newly created project and module
Create and deploy the Web project
Expand the project and module nodes in the navigator view, and locate the WebContent folder. This folder contains the files to be placed in your resulting Web application. From the pop-up menu on this icon, create a new HTML file. You can name the file anything you want, and just enter some simple HTML text in the editor when it appears. In the navigator view, select your newly created file, bring up the pop-up menu, and select Run As > Run on server. When the dialog appears, ensure the Geronimo server is selected, select the check box to set Geronimo as the default for this project, and then select Finish. The Web application is now created and deployed to the running Geronimo server, and a Web browser opens showing the file you have just created. If you prefer not to have an external browser opening, Eclipse can use a browser within an embedded window: To set your preference, select Open window > Preferences > General > Web browser.
Now that you have successfully deployed your Web project, you can explore how to debug applications in Eclipse. The simplest way to do this is to add a JSP file to the newly created Web application.
The first step is to return to the Navigator view and use the pop-up menu to create a new JSP file in the WebContent folder. In the JSP editor that then opens, add some very basic content to the JSP including some embedded Java code, such as the sample shown in Figure 5. You can now set a breakpoint in that Java code by double-clicking on the left column on the appropriate line.
The next step is to restart the Geronimo server in debug mode. When the WTP project is completed, this action will happen automatically, but for now you need to manually restart the server in "Debug" mode. Select the Servers tab in the bottom right pane and from the pop-up menu, stop the Geronimo server, and then start it again in "Debug" mode. You can now select the new JSP that you created, and from its pop-up menu select Debug as > Debug on server. Your newly created JSP is compiled, the application is redeployed to the server, and the debugger stops at the line you put the breakpoint on. You can now step through your JSP, viewing and changing variable values as you go, and when you continue execution (using the green arrow), the JSP is served into the Web browser.
Figure 5. The JSP is served into the Web browser
You can make any needed changes to your application, and then select the Run on server action, as described, to have your changes redeployed to Geronimo. The "Publish" action from the servers view will also redeploy all the applications associated with the selected server.
Geronimo Web applications have their basic behavior defined in a deployment plan. For Web applications, this plan is named geronimo-jetty.xml, and it is located in the WebContent > WEB-INF directory. A basic deployment plan is created for you if one does not exist when you deploy your application to Geronimo. You must modify this file to specify a new context route for your application. An editor is available to manipulate the basic aspects of this file. To use the editor, locate the file in the navigator view, and select Open with > Deployment plan editor to open the editor. Some aspects of the deployment plan are not yet represented within the editor; that data is not displayed within the editor, but it will not be lost when the file is saved.
Figure 6. Geronimo deployment plan editor
The Geronimo server adapter plug-in is still very much in its infancy. It provides basic support for interaction with Geronimo, but much work to improve and perfect it yet remains. The plug-in is being developed as part of the Eclipse WTP project, and interested developers are encouraged to visit the Eclipse site and contribute to the plug-in’s ongoing development.
- Get more information about the Web Tools Platform project from eclipse.org.
- Download Gluecode Standard Edition, an open source application server based on Apache Geronimo.
- Download the M4 milestone of WTP.
- Take a look at the developerWorks interview with Jeremy Boynes (developerWorks, May 2005) to get an overview of the Gluecode acquisition and what it means to open source development.
- Tim coauthored Professional IBM WebSphere 5.0 Application Server
(Wrox Press, 2002), which details how to develop, deploy, and manage enterprise applications for IBM WebSphere® Application Server Version 5.0.
- Find more articles for Eclipse users on developerWorks.
- Visit the developerWorks developerWorks Open source zone for extensive how-to information, tools, and project updates to help you develop with open source technologies and use them with IBM's products.
- Innovate your next open source development project with IBM trial software, available for download or on DVD.
- Browse for books on these and other technical topics.
- Get involved in the developerWorks community by participating in
developerWorks blogs.

Tim Francis is a Senior Technical Staff Member and architect of the WebSphere Tools team in the IBM Canada Toronto Lab. He received a BASc in Electrical Engineering from the University of Waterloo and an MMath in Software Engineering from the University of Waterloo, and joined IBM in 1990. Tim is a senior member of the WebSphere Architecture Board, and a core member of the Rational Tools Development Council. Tim coauthored the J2EE book Professional IBM WebSphere 5.0 Application Server (Wrox Press, 2002).



