JBoss Tools 3 Developers Guide
上QQ阅读APP看书,第一时间看更新

JBoss AS plug-in and the Eclipse Web Tools Platform

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).
    Adding a WTP Runtime in Eclipse
  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.
    Adding a WTP Runtime in Eclipse

    Note

    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 book 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.
    Adding a WTP Runtime in Eclipse

    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:

    4.1 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.

    4.2 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.

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

    Note

    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.
    Adding a WTP server in Eclipse
  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 chapter (as shown in the following screenshot). After that click on the Next button.
    Adding a WTP server in Eclipse
  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.
    Adding a WTP server in Eclipse
  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).
    Adding a WTP server in Eclipse

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