Chapter 6. Eclipse and J2EE

Table of Contents

To develop web services with Eclipse a couple of plugins are recommended. The Tomcat plugin of Sysdeo is well suitable for simple projects with Tomcat as application server. Since I would like to develop and debug web services with Tomcat as container later, it is used in this project. Substantially however the Lomboz Plugin of ObjectLearn supplies more functionality. In addition, it is primarily helpful for developing EJB applications, but also has a few functions for web services.

Optionally, the plugin JBOSS IDE can be used, in order to steer XDoclet more comfortably. I will present both kinds „manually “ (by ant script) and with JBOSS IDE.

6.1. Tomcat plugin from Sysdeo

First unpack the zip archiv in the directory hierarchy. After restarting Eclipse you can configure the plugin in „Windows / Preferences“:

Figure 6.1.  configure the tomcat plugin

The most important properties are:

  • Tomcat version
  • Tomcat home directory
  • Tomcat config file (server.xml) to use

Thus the Plugin can be used. In „Windows/Customize Perspective“ one activates the plugin in the „Debug-Perspective“:

Figure 6.2.  activate tomcat plugin

Three new buttons are added to toolbar with which Tomcat can be start and stop directly from Eclipse.

The interesting thing is, that you can debug a web service including Tomcat in Eclipse by placing breakpoints in a doGet method of a servlet or in a web service method.

6.1.1. Project as „Tomcat project“

From now on you can choose „Tomcat project“, when creating a new project. An existing project can be change to „Tomcat project“ in „Project-Properties“:

Figure 6.3.  tomcat project properties

  • Check „Is a tomcat project“.
  • Application URI must contain the context path for Tomcat.
  • If „can actualise XML“ is checked, the Tomcat context will be updated in the server.xml automatically.
  • „WAR file for export“ sets the name of the war file, when the project is exported. The name is an absolute pathname, referencing directly to the directory where the war file is deployed.

If everything is set up like this, then the context menu of the project has an additional entry :

  • Figure 6.4.  tomcat project options in context menu

    Export WAR[3] file.
  • The context in the Tomcat configuration file (server.xml) can be removed and/or updated.
  • The Tomcat libraries can be added to the project.
  • Create a work directory, which takes the generated servlets from JSP pages.

Footnotes

[3] (W)eb-(A)pplication-A(R)chive