Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
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:
- From the Window menu, select Open Perspective | Other article.
- In the Open Perspective window, select the JBoss AS option and click on OK button (as shown in the following screenshot).
- If everything works fine, you should see the JBoss AS perspective as shown in the following screenshot:
- 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 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:
- 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).
- 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).
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.
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.
- 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.
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).
- 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).
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
- Publishing: Allows you to see if changes are being updated
- Republish: Allows you to see if changes are waiting
eBook Price: $23.99
Book Price: $39.99
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:
- Select the Preferences window from the Window main menu.
- In the Preferences window, expand the Server node, and select the JBoss Server View leaf(as shown in the following screenshot).
- 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).
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).
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).
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:
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).
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).
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.
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.
- 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.
- 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:
If you look in the Properties view, you should see the following XPaths (as shown in the following screenshot):
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:
eBook Price: $23.99
Book Price: $39.99
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:
- 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.
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.
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:
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.
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:
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).
- 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):
- In Package Explorer view, right-click on the test node and select the Properties option from the contextual menu.
- In the Properties window, select the Project Facets node (as shown in the following screenshot).
- 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).
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.
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).
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).
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.
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 :
The author is a senior Java developer with more than 12 years of experience in Java SE, Java EE, and the related frameworks. He has written and published more than 20 articles about Java technologies and more than 100 tips and tricks. He has also written two books about XML and Java (one for beginners and one for advanced developers). During this time, he has developed web applications using the latest technologies on the market. In the past two years, he has focused on developing RIA projects for GIS fields. He is interested to bring on web as much desktop as possible, therefore GIS applications represents a real challenge for him.
Books From Packt