JBoss AS Perspective

Exclusive offer: get 50% off this eBook here
JBoss Tools 3 Developers Guide

JBoss Tools 3 Developers Guide — Save 50%

Develop JSF, Struts, Seam, Hibernate, jBPM, ESB, web services, and portal applications faster than ever using JBoss Tools for Eclipse and the JBoss Application Server

$23.99    $12.00
by Anghel Leonard | April 2009 | JBoss Java Open Source Web Development

In the previous article, we learnt how to configure the JBoss AS server and runtime in Eclipse. In this article by Anghel Leonard, 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.

As you know, Eclipse offers an ingenious system of perspectives that helps us to switch between different technologies and to keep the main-screen as clean as possible. Every perspective is made of a set of components that can be added/removed by the user. These components are known as views.

The JBoss AS Perspective has a set of specific views as follows:

  • JBoss Server View
  • Project Archives View
  • Console View
  • Properties View

For launching the JBoss AS Perspective (or any other perspective), follow these two simple steps:

  1. From the Window menu, select Open Perspective | Other article.
  2. In the Open Perspective window, select the JBoss AS option and click on OK button (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

  3. If everything works fine, you should see the JBoss AS perspective as shown in the following screenshot:
    JBoss Tools 3 Developers Guide
  4. If any of these views is not available by default in your JBoss AS perspective, then you can add it manually by selecting from the Window menu the Show View | Other option. In the Show View window (shown in the following screenshot), you just select the desired view and click on the OK button.

    JBoss Tools 3 Developers Guide

JBoss Server View

This view contains a simple toolbar known as JBoss Server View Toolbar and two panels that separate the list of servers (top part) from the list of additional information about the selected server (bottom part). Note that the quantity of additional information is directly related to the server type.

Top part of JBoss Server View

In the top part of the JBoss Server View, we can see a list of our servers, their states, and if they are running or if they have stopped.

Starting the JBoss AS

The simplest ways to start our JBoss AS server are:

  1. Select the JBoss 4.2 Server from the server list and click the Start the server button from the JBoss Server View Toolbar (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

  2. Select the JBoss 4.2 Server from the server list and right-click on it. From the context menu, select the Start option (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

In both cases, a detailed evolution of the startup process will be displayed in the Console View, as you can see in the following screenshot.

JBoss Tools 3 Developers Guide

Stopping the JBoss AS

The simplest ways to stop JBoss AS server are:

  • Select the JBoss 4.2 Server from the server list and click the Stop the server button from the JBoss Server View Toolbar.

    JBoss Tools 3 Developers Guide

  • Select the JBoss 4.2 Server from the server list and right-click on it. From the context menu, select the Stop option.

In both cases, a detailed evolution of the stopping process will be displayed in the Console View, as you can see in the following screenshot.

JBoss Tools 3 Developers Guide

Additional operations on JBoss AS

Beside Start and Stop operations, JBoss Server View allows us to:

  • Add a new server (the New Server option from the contextual menu)
  • Remove an existing server (the Delete option from the contextual menu)
  • Start the server in debug mode (first button on the JBoss Server View Toolbar)
  • Start the server in profiling mode (third button on the JBoss Server View Toolbar)
  • Publish to the server or synching the publish information between the server and the workspace (the Publish option from the contextual menu or the last button on the JBoss Server View Toolbar)
  • Discard all publish state and republish from scratch (the Clean option from the contextual menu)
  • Twiddle server (the Twiddle Server option from the contextual menu)
  • Edit launch configuration (the Edit Launch Configuration option from the contextual menu as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

  • Add/remove projects (the Add and Remove Projects option from the contextual menu)
  • Double-click the server name and modify parts of that server in the Server Editor—if you have a username and a password to start the server, then you can specify those credentials here (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

Twiddle is a JMX library that comes with JBoss, and it is used to access (any) variables that are exposed via the JBoss JMX interfaces.

Server publish status

A server may have one of the following statuses:

  • Synchronized: Allows you to see if changes are sync (as shown in the follo

    JBoss Tools 3 Developers Guide

    wing screenshot)

  • Publishing: Allows you to see if changes are being updated
  • Republish: Allows you to see if changes are waiting
JBoss Tools 3 Developers Guide Develop JSF, Struts, Seam, Hibernate, jBPM, ESB, web services, and portal applications faster than ever using JBoss Tools for Eclipse and the JBoss Application Server
Published: April 2009
eBook Price: $23.99
Book Price: $39.99
See more
Select your format and quantity:

Bottom part of JBoss Server View

The bottom part of JBoss Server View offers a set of additional information structured in six categories. By default, all categories are visible, but you can add or remove a category like this:

  1. Select the Preferences window from the Window main menu.
  2. In the Preferences window, expand the Server node, and select the JBoss Server View leaf(as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

  3. After you select all the categories (or a sub-set of categories), click on the Apply and OK buttons. Note that the selected categories appear in the JBoss Server View (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

Modules category

This category will show you the modules that are currently deployed on the server through Eclipse support. You can remove, full publish, and incremental publish a module by the contextual menu's options that appear when you right-click on a module (as shown in the following screenshot).

JBoss Tools 3 Developers Guide

Event Log category

As the name suggests, this category is an events log reporter. You will get information about important events like start/stop of the server and publishing tasks. Detailed information will appear in the Properties view every time you select a subcategory of Event Log. At any moment, you can clear the Event Log reports by selecting the Clear Event Log option from the contextual menu that appears when you right-click on this category (as shown in the following screenshot).

JBoss Tools 3 Developers Guide

Notice that in the above screenshot we have selected a task related to the Publishing operation. The following output is displayed in the Properties View:

JBoss Tools 3 Developers Guide

XML configuration category

This category is focused on working with XML descriptors files. It has a default Ports subcategory that fills up the Properties view with a series of nodes (sections) that contain paths indicating locations of XML descriptors. Also, we can see a list of values that are associated with XML components (elements, attributes) that belong to those XML descriptors. As you can see, by default, these values are the most used ports of our JBoss AS (as shown in the following screenshot).

JBoss Tools 3 Developers Guide

These paths and values are extracted by using XPath expressions dedicated to filter XML elements and attributes. In the following screenshot, you can see the XPath expression that corresponds to the Web Services field. Note that for displaying an XPath expression, you can select the section from the Properties view, right-click on it, and select the Edit XPath option. You may also create a new XPath under that section (using the New XPath option) or delete an existing XPath (using the Delete XPath option).

JBoss Tools 3 Developers Guide

If you are not familiar with XPath vocabulary, then you should consult a specialized tutorial.

If you want to create a new subcategory in the XML Configuration category, right-click on it and select the New Category option from the contextual menu. You will be prompted for the subcategory's name and after that it will be added under XML Configuration category. As per our example, in the following screenshot, we have created a subcategory named MyPorts.

JBoss Tools 3 Developers Guide

Going further, you can create a new XPath expression by right-clicking on a subcategory name and selecting the New XPath option. This will display the New XPath window where you can set the new XPath's characteristics. Note that you will be sustained by the auto-completion facility for obtaining the desirable XPath expression. Next, we'll see three examples of new XPath expressions:

  • The following screenshot shows you how to create an XPath expression named testPorts_1, which will be a shortcut for changing the text of all elements named attribute that contain an Attribute Name with the value BaseDir. Note that the location and value are extracted after you click on the Preview button. If what you see in the preview panel is what you want, then click on the OK button and the new XPath will be added in the MyPorts subcategory. It will also be visible in the Properties view.

    JBoss Tools 3 Developers Guide

  • If we want to create an XPath expression named testPorts_2, which will be a shortcut for changing the text of all elements named attribute that contain an Attribute Name with any value, the following screenshot shows how to do it.

    JBoss Tools 3 Developers Guide

  • If we want to create an XPath expression named testPorts_3, which will be a shortcut for changing the values of all attributes' name that belong to elements named attribute, the following screenshot shows you how to do it:

    JBoss Tools 3 Developers Guide

If you look in the Properties view, you should see the following XPaths (as shown in the following screenshot):

JBoss Tools 3 Developers Guide

Now, for changing an element's/attribute's value, just double-click inside the Properties view on the right XML file and modify the associated value.

JMX Console category

The JMX Console is a special category that offers access to the JMX beans on the server. What follows is a screenshot of the JMX Console:

JBoss Tools 3 Developers Guide

JBoss Tools 3 Developers Guide Develop JSF, Struts, Seam, Hibernate, jBPM, ESB, web services, and portal applications faster than ever using JBoss Tools for Eclipse and the JBoss Application Server
Published: April 2009
eBook Price: $23.99
Book Price: $39.99
See more
Select your format and quantity:

Project archives view

As a Java developer, you should be familiar with notions like JAR, WAR, and EAR archives, and I'm sure that you know what they are good for and how to create such archives by using different tools. Packaging Java applications in these kind of archives is one of the main goals of the Project archives view. For this, you should start by using the Project archives view, which is able to create and set up each packaging configuration. Note that by packaging configuration, we understand an XML file named .packages that is stored in every project's root folder.

For creating an archive, you have two options:

  • If the project has no .packages file, then in the Project archives view you will see something like what is shown in the following screenshot. Here, just click on the desirable archive type:

    JBoss Tools 3 Developers Guide

  • If the project has a .packages file, then you should move the mouse cursor inside the Project archives view and right-click here (shown in the following screenshot) for displaying the context menu.

    JBoss Tools 3 Developers Guide

As you can see, there are four types of archives available. All of them have a common wizard-page used to configure the archive name, destination (anywhere on your computer), and type (exploded or packaged). The following screenshot is a wizard-page form displayed for JAR archives, but it belongs to WAR, EJB JAR, and EAR archives as well.

JBoss Tools 3 Developers Guide

In case of a WAR, EJB JAR, and EAR archive, we also have a second wizard-page that presents a preview of the archive's stub. The following screenshot is a preview of the archive's stub of a WAR archive:

JBoss Tools 3 Developers Guide

After the archive is created (when you clicked on the Finish button), it will appear in the Project archives view as you can see in the following screenshot where we have created a WAR archive, named test.war.

JBoss Tools 3 Developers Guide

Now, a new set of operations become available. For seeing these operations, just right-click on the archive name (or on a nested archive or on a folder within an archive), as shown in the following screenshot:

JBoss Tools 3 Developers Guide

As you can see, here there are options for:

  • Creating a new folder (the New Folder option)
  • Creating a new fileset (the New Fileset option)
  • Building an archive (the Build Archive option)
  • Editing an archive (the Edit Archive option)
  • Deleting an archive (the Delete Archive option)
  • Publishing to server (the Publish To Server option as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

  • Editing publish settings (the Edit publish settings … option)

Creating and deploying projects

An important category of projects that can be developed/deployed through Eclipse and JBoss Tools are faceted projects. Usually, these projects start from an empty Dynamic Web Project and are decorated with different facets. In this category, we have projects like:

  • Struts projects
  • Seam projects
  • JSF projects
  • J2EE projects
  • Include facets in an existing project
  • Include facets when a project is created

To include facets in an existing project, you have to follow these steps (we are showing you for the test project, but they are available for any other project):

  1. In Package Explorer view, right-click on the test node and select the Properties option from the contextual menu.
  2. In the Properties window, select the Project Facets node (as shown in the following screenshot).

    JBoss Tools 3 Developers Guide

  3. In this wizard, middle panel, you can select/deselect facets. In addition to this, you can select a target runtime from the right-panel, by switching to Runtimes tab and selecting/deselecting the desired runtimes. Finally, click on the Apply and OK buttons.

Depending on the selected facets, we have to provide additional configuration or meet dependency criteria. As per our example, if we select the JavaServer Faces facet, then a red bullet and a link will indicate that further configurations are required (as shown in the following screenshot).

JBoss Tools 3 Developers Guide

Facet dependencies are also reported as shown in the following screenshot, where we have selected the JBoss Seam Portlet facet. The warning messages will disappear when all the selected facets respect their dependencies.

JBoss Tools 3 Developers Guide

Now, speaking about the deployment process, you have to know that this can be accomplished in different ways from different contexts through WTP and JBoss Tools support. For example, the most used deployment schemas are:

  • Deploy from JBoss Server View
  • Deploy from the Package Explorer

From the JBoss Server View, you can use the Add and Remove Projects option from the contextual menu that appears when you right-click on the server name in the top part of this view. This wizard was presented earlier in Adding a WTP Server in Eclipse section and it allows you to add or remove a project by two simple and intuitive panels.

In the bottom part of the same view, you can expand the Modules section and right-click on a module for selecting the Full Publish/Incremental Publish options from the contextual menu. Notice that by incremental publish, we understand that the only parts to be published will be those where changes have been made.

Now, if you want to deploy your projects from the Package Explorer view then you should select the Run As | Run on Server option from the contextual menu that is displayed when you right-click on a project name (as shown in the following screenshot).

JBoss Tools 3 Developers Guide

This option will display a wizard for selecting the server that will host the project. Clicking on the Next button will display the wizard that was presented earlier in Adding a WTP Server in Eclipse section. After you add/remove the projects, you should click on the Finish button and wait until the deployment/un-deployment is successfully done!

If you want to deploy single files/projects that are non-WTP then right-click on them, and from the contextual menu, select the Deploy to Server option (as shown in the following screenshot).

JBoss Tools 3 Developers Guide

Now, if you take a look in the Modules section from the JBoss Server View, you will see the deployed files at the same level as other projects.

Summary

In two-part article series, we first saw how to configure the JBoss AS server and runtime in Eclipse. In this article, we saw a brief description of creating and deploying J2EE applications on the chosen server. All these operations are required to be able to start developing projects through JBoss Tools support.

 

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

About the Author :


Anghel Leonard

Anghel Leonard is a senior Java developer with more than 13 years of experience in Java SE, Java EE, and related frameworks. He has written and published more than 50 articles about Java technologies and more than 500 tips and tricks for many websites that are dedicated to programming. In addition, he has written the following books:

  • Tehnologii XML XML în Java, Albastra
  • Jboss Tools 3 Developer's Guide, Packt Publishing
  • JSF 2.0 Cookbook, Packt Publishing
  • JSF 2.0 Cookbook: LITE, Packt Publishing
  • Pro Java 7 NIO.2, Apress
  • Pro Hibernate and MongoDB, Apress

Currently, Anghel is developing web applications using the latest Java technologies on the market (EJB 3.0, CDI, Spring, JSF, Struts, Hibernate, and so on). Over the past two years, he's focused on developing rich Internet applications for geographic information systems.

Books From Packt

 

JBoss Portal Server Development
JBoss Portal Server Development

JBoss Drools Business Rules
JBoss Drools Business Rules

Learning jQuery 1.3
Learning jQuery 1.3

Spring Web Flow 2 Web Development
Spring Web Flow 2 Web Development

Java EE 5 Development with NetBeans 6
Java EE 5 Development with NetBeans 6

Django 1.0 Website Development
Django 1.0 Website Development

Drupal 6 Site Builder Solutions
Drupal 6 Site Builder Solutions

Practical Plone 3: A Beginner's Guide to Building Powerful Websites
Practical Plone 3: A Beginner's Guide to Building Powerful Websites

 

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software