JBoss AS plug-in and the Eclipse Web Tools Platform

In this article, we recommend that you use the JBoss AS (version 4.2), which is a free J2EE Application Server that can be downloaded from http://www.jboss.org/jbossas/downloads/ (complete documentation can be downloaded from http://www.jboss.org/jbossas/docs/).

JBoss AS plug-in and the Eclipse WTP

JBoss AS plug-in can be treated as an elegant method of connecting a J2EE Application Server to the Eclipse IDE. It's important to know that JBoss AS plug-in does this by using the WTP support, which is a project included by default in the Eclipse IDE. WTP is a major project that extends the Eclipse platform with a strong support for Web and J2EE applications. In this case, WTP will sustain important operations, like starting the server in run/debug mode, stopping the server, and delegating WTP projects to their runtimes. For now, keep in mind that Eclipse supports a set of WTP servers and for every WTP server you may have one WTP runtime.

Now, we will see how to install and configure the JBoss 4.2.2 runtime and server.

Adding a WTP runtime in Eclipse

In case of JBoss Tools, the main scope of Server Runtimes is to point to a server installation somewhere on your machine. By runtimes, we can use different configurations of the same server installed in different physical locations. Now, we will create a JBoss AS Runtime (you can extrapolate the steps shown below for any supported server):

  1. From the Window menu, select Preferences.
  2. In the Preferences window, expand the Server node and select the Runtime Environments child-node. On the right side of the window, you can see a list of currently installed runtimes, as shown in the following screenshot, where you can see that an Apache Tomcat runtime is reported (this is just an example, the Apache Tomcat runtime is not a default one).

    JBoss Tools 3 Developers Guide

  3. Now, if you want to install a new runtime, you should click the Add button from the top-right corner. This will bring in front the New Server Runtime Environment window as you can see in the following screenshot. Because we want to add a JBoss 4.2.2 runtime, we will select the JBoss 4.2 Runtime option (for other adapters proceed accordingly). After that, click Next for setting the runtime parameters.

    JBoss Tools 3 Developers Guide

    In the runtimes list, we have runtimes provided by WTP and runtimes provided by JBoss Tools (see the section marked in red on the previous screenshot). Because this article is about JBoss Tools, we will further discuss only the runtimes from this category. Here, we have five types of runtimes with the mention that the JBoss Deploy-Only Runtime type is for developers who start/stop/debug applications outside Eclipse.

  4. In this step, you will configure the JBoss runtime by indicating the runtime's name (in the Name field), the runtime's home directory (in the Home Directory field), the Java Runtime Environment associated with this runtime (in the JRE field), and the configuration type (in the Configuration field).In the following screenshot, we have done all these settings for our JBoss 4.2 Runtime.

    JBoss Tools 3 Developers Guide

    The official documentation of JBoss AS 4.2.2 recommends using JDK version 5. If you don't have this version in the JRE list, you can add it like this:

    • Display the Preferences window by clicking the JRE button. In this window, click the Add button to display the Add JRE window. Continue by selecting the Standard VM option and click on the Next button. On the next page, use the Browse button to navigate to the JRE 5 home directory.
    • Click on the Finish button and you should see a new entry in the Installed JREs field of the Preferences window (as shown in the following screenshot). Just check the checkbox of this new entry and click OK. Now, JRE 5 should be available in the JRE list of the New Server Runtime Environment window.

      JBoss Tools 3 Developers Guide

  5. After this, just click on the Finish button and the new runtime will be added, as shown in the following screenshot:

    JBoss Tools 3 Developers Guide

    From this window, you can also edit or remove a runtime by using the Edit and Remove buttons. These are automatically activated when you select a runtime from the list.

  6. As a final step, it is recommended to restart the Eclipse IDE.

Adding a WTP server in Eclipse

By a WTP server, we mean an Eclipse-mechanism that is able to control the main operations of a real server (start/stop/debug/deploy/un-deploy operations). In other words, a WTP server is an Eclipse representation of a backing server installation.

For installing a new server, we can follow these steps:

  1. From the File menu, select the New | Other… option.
  2. This option will open the New window (shown in the following screenshot). In this window, expand the Server node and select the Server child-node. After that click on the Next button.

    JBoss Tools 3 Developers Guide

  3. In the New Server window, you have to configure the new server settings by selecting the server's host name (in Server's host name list), the server type (in the Select the server type panel), and the associated runtime (from the Server runtime environment list). In case you don't have any runtime or you want to create a new runtime, just click on the Add link to open the New Server Runtime Environment window (this wizard was presented in the previous section). In addition to this, if you want to configure an existing runtime, then follow the Configure runtime environments link. In our example, you can choose the localhost host, the JBoss AS 4.2 server type, and the JBoss 4.2 runtime that was created in the previous section of this article (as shown in the following screenshot). After that click on the Next button.

    JBoss Tools 3 Developers Guide

  4. In this step, you can specify a name for your server (in the Name field, type JBoss 4.2 Server) and the login credentials for the JMX console (in the Login Credentials field). This window also offers a brief overview of the settings made in the previous steps and a good chance to adjust them before the last step of this process (as shown in the following screenshot). When you are ready, click on the Next button.

    JBoss Tools 3 Developers Guide

  5. This step will allow you to add/remove your currently available projects to/from this new server. For adding a project, you select that project from the left panel and press the Add button and for removing a project, you select it from the right panel and press the Remove button. When you are done, just click on the Finish button. By default, no projects are provided, so the list is empty (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

The new server was added! Just restart the Eclipse IDE.

Creating our first web project—a dynamic web project stub

Now that we have installed and configured a JBoss AS 4.2 server instance, it is time to create our first web project. To be honest with you, this is less of a useful project and more of an "instrument" used to reveal as much as possible the facilities of JBoss AS Tools.

So, we decide to use a Dynamic Web Project stub, created straightforward from the New menu | Other | Web node | Dynamic Web Project leaf (Eclipse helps you organize your web applications using a type of project called a Dynamic Web Project). In the creation wizard, just type the test name as the project name and click the Finish button (note that the target runtime was automatically detected as JBoss 4.2, while the rest of fields were filled-up with the default values). Without a web project, many of the JBoss Tools AS facilities will be disabled.

Deploying the test project on JBoss 4.2 Server

Deploying a project is a task that can be accomplished in many ways. The quickest solution consists of right-clicking on the JBoss 4.2 Server node (in JBoss Server View) and selecting Add and Remove Projects option. This will open the wizard (the one shown in the previous screenshot), but this time, in the left panel, you can see the test project. Select it, click the Add button, and close the wizard by clicking on the Finish button. When the JBoss 4.2 Server will be started, the new project will be deployed.


This article is essential for a good and easy understanding of any further implementations. You have learnt how to configure the JBoss AS server and runtime in Eclipse. In the next article we will see how to use the JBoss AS Tools to start/stop your server, how to manage the server's statuses, and how to deploy/un-deploy/manage your projects.


If you have read this article you may be interested to view :

You've been reading an excerpt of:

JBoss Tools 3 Developers Guide

Explore Title