JBoss Tools 3 Developers Guide - Anghel Leonard - E-Book

JBoss Tools 3 Developers Guide E-Book

Anghel Leonard

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

JBoss Tools consist of the best Java frameworks and technologies placed together under the same "roof". Discovering JBoss Tools is like exploring a cave; at first everything seems unknown and complicated, but once you become familiar with the main features of the Tools, you will start to feel at home.

This is the first book in the market on JBoss Tools, waiting to assist you to throw away all the tiny, dedicated tools you have used earlier, thus helping you to reduce the time you spend on developing a Java application. This book will explore the tools that will help you to build Hibernate, Seam, JSF, Struts, Web Services, jBPM, ESB, and so on and show you how to use them through screenshots, examples, and source code. JBoss Tools comes with a set of dedicated wizards, generators, editors, reverse engineering capabilities, configuration files, templates, syntax highlighting, and more for each of these technologies. Just choose the technologies, and JBoss Tools will glue them together in amazing Java web applications.

This book will show you how to develop a set of Java projects using a variety of technologies and scenarios. Everything is described through JBoss Tools "eyes". After we settle the project (or scenario) that will be developed, we configure the proper environment for the current tool (the selected projects cover the main components of a web application, with regard to the backstage technology). We continue by exploring the tool to accomplish our tasks and develop the project's components. A cocktail of images, theoretical aspects, source code, and step-by-step examples will offer you a complete insight into every tool.

At the end, we deploy and test the project. In addition, every chapter is rich with pure notions about the underlying technology, which will initiate into you or remind you of the basic aspects of it. It will also show you complete and functional applications, and get you familiar with the main aspects of every tool. By the end you will have enough information to successfully handle your own projects with JBoss Tools.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 381

Veröffentlichungsjahr: 2009

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

JBoss Tools 3 Developer's Guide
Credits
About the Author
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code for the book
Errata
Piracy
Questions
1. An overview of JBoss Tools
What's new in JBoss Tools 3?
Installing JBoss Tools
Installing Eclipse version 3.4.x (Eclipse Ganymede)
Installing JBoss Tools through Eclipse software updates
Manual installation of JBoss Tools
Summary
2. JBoss AS Tools
JBoss AS plug-in and the Eclipse Web Tools Platform
Adding a WTP Runtime in Eclipse
Adding a WTP server in Eclipse
Creating our first web project—a dynamic web project stub
Deploying the test project on JBoss 4.2 Server
JBoss AS Perspective
JBoss Server View
Top part of JBoss Server View
Starting the JBoss AS
Stopping the JBoss AS
Additional operations on JBoss AS
Server publish status
Bottom part of JBoss Server View
Modules category
Event Log category
XML configuration category
JMX Console category
Project archives view
Creating and deploying projects
Summary
3. JBoss Tools Palette
JBoss Tools Palette Toolbar
Palette Editor
Creating a set of icons
Importing an icon
Creating a group of tag libraries
Creating a tag library
Creating a new tag
Show/Hide
Importing third-party tag libraries
Using tags in text files
Summary
4. JSF Tools
Overview of JSF
Creating a JSF project stub
JSF Project Verification
JSF application configuration file
The Diagram view
Creating pages
Adding navigation rules
The Tree view
Working with Managed Beans
Working with custom converters
Working with custom validators
The Source view
Editing pages code sources
Editing the register.jsp page
Editing the success.jsp page
Editing a start page for the registerJSF project
Testing the registerJSF project
Adding/Removing JSF capabilities for an existing project
Facelets support
Summary
5. Struts Tools
Overview of Struts
Struts project verification
Creating a Struts project stub
Struts editors
Graphical editor for struts-config.xml
Diagram view
Creating JSP pages
Creating an action mapping
Connecting a JSP page with action mappings
Creating a forward
Creating a global forward
Creating a global exception
Let's add some code inside JSPs
Generate source code
Tree view
Creating a form bean
Source view
Graphical editor for tiles files
Creating a new tiles file
Tree view
Diagram view
Source view
Create a start page for the registerStruts application
Testing registerStruts application
Struts Tools and validation aspects
Turning on the automatic validator
Creating the properties file for validation purposes
Graphical editor for validation files
Custom message for the name property (required rule)
Custom message for the zip property (required and mask rules)
Custom message for the email property (required and email rules)
Client-side validation
Server-side validation
Debugging support for Struts projects
Summary
6. Seam Tools
Overview of Seam
Preparations
Creating a new Seam project
General section
Database section
Code Generation section
Test testSeam project
Creating Seam components
Creating a Seam Action
Creating a Seam Form
Creating a Seam Conversation
Creating a Seam Entity
Seam views
Seam Components view
Project Explorer view
Using TestNG for Seam projects
Generating a Seam project from an existing database
Running the generated Seam application (generateSeam)
Modify Seam preferences
Summary
7. Hibernate Tools
Overview of Hibernate
Preparations
Hibernate Tools for Eclipse
Manual installation
Hibernate perspective
Creating a Hibernate mapping file (.hbm.xml)
Hibernate XML Editor
Tree View
Adding a <class> element
Adding an <id> element
Adding a <property> element
Adding a <set> element
Adding a <one-to-many> element
Creating a Hibernate configuration file
Hibernate Configuration XML Editor
Session Factory view
Security view
Source view
Creating a Hibernate Console Configuration
Main tab
Options tab
Classpath tab
Mappings tab
Common tab
Hibernate Configurations view
Mapping diagram
HQL Editor
Hibernate Criteria Editor
Hibernate Query Result view
Hibernate Dynamic SQL Preview view
Query Parameters view
Properties view
Reverse engineering and code generation techniques
Main tab
Exporters tab
Refresh tab
Common tab
Generating Hibernate artifacts
Customize and control reverse engineering (reveng.xml)
Overview view
Table Filters view
Type Mappings view
Table & Columns view
Design view
Source view
Hibernate Tools for Ant
The <hibernatetool> Ant Task
Adding Hibernate tools dependencies
Hibernate Configurations
Hibernate Tools exporters
Hibernate Mapping Files Exporter
POJOs Exporter
Hibernate Configuration File Exporter
Database Schema Exporter
Documentation Exporter
Query Exporter
Import all libraries dependencies
Summary
8. jBPM Tools
Downloading and installing the JBoss jBPM Suite
Creating a jBPM stub project
Creating a jBPM process definition
Launching the jBPM JPDL perspective
jBPM GPD Editor
Diagram view
Adding states
Adding task-nodes
Adding nodes
Adding a fork-join system
Adding a mail node
Adding transitions
Customizing node names
Customizing transition's names
Defining swimlanes
Defining a task for the start-state
Defining a task for the task-node
Decorating graph with actions
Configuring Mail node
Source view
Design view
Deployment view
Running a process on JBoss jBPM server
Creating a JUnit test for a jBPM process
Summary
9. ESB Tools
Downloading and installing the JBossESB Server
Creating a JBossESB stub project
JBoss ESB Editor
Defining a Service skeleton in JBossESB
Defining the Action Pipeline
Defining a list of Listeners
Configuring message queues in JBossESB Server
Indicating the classes loading order
Sending an ESB Message through the ServiceInvoker
Sending a JMS Message in a classical manner
Service Registry configuration
Importing the "endorsed" libraries
Preparing and deploying a Service on JBossESB Server
Testing the ESB Service
What just happened?
Summary
10. Web Services Tools—JBossWS
Overview of Web Services
Downloading and installing JBossWS Native
Configuring JBossWS under Eclispe IDE
Creating a web service using Web Services Tools
Adding the JBoss Web Service facet
Writing a WSDL document using the WSDL wizard
Generating the web service from a WSDL document
Providing service business logic
Generating the web service's client from a WSDL
Providing client business logic
Deploying and testing a web service
Testing a web service through Web Services Explorer
Creating a Web service from a Java bean
Publishing web services and business entities
A brief introduction to UDDI
JBoss AS 4.2 and jUDDI
Preparing the jUDDI database
Using Web Services Explorer as a UDDI Browser
Adding a Registry to the Web Services Explorer
Publishing a business entity
Publishing a web service
Discovering our own web service through WSE
Discovering "external" web service through WSE
WSDL to WSIL, WSIL in WSE
Convert WSDL to WSIL
WSIL and WSE
Summary
11. JBoss Portal Tools
Overview of Portals and Portlets
Downloading and installing JBoss Portal + JBoss AS
Configuring the JBoss Portal bundle under Eclipse IDE
Starting JBoss Portal
Adding a Java portlet in JBoss Portal
Adding JBoss Portlets Facet
Creating a Java Portlet
Deploying and running a portlet
Adding a JSP portlet in JBoss Portal
Creating a JSP Portlet
Implementing the init method
Implementing the doView method
Implementing the view.jsp page
Implementing the doEdit method
Implementing the edit.jsp page
Implementing the doHelp method
Implementing the help.jsp page
Implementing the processAction method
Writing and configuring a dedicated validator
Adding a JSF portlet in JBoss Portal
Adding a Seam portlet in JBoss Portal
Summary
Index

JBoss Tools 3 Developer's Guide

Anghel Leonard

JBoss Tools 3 Developer's Guide

Copyright © 2009 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2009

Production Reference: 1090409

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-847196-14-9

www.packtpub.com

Cover Image by Karl Moore (<[email protected]>)

Credits

Author

Anghel Leonard

Reviewers

Joseph Edem Morny

Peter Johnson

Acquisition Editor

Sarah Cullington

Development Editor

Dhiraj Chandiramani

Technical Editor

Abhinav Prasoon

Copy Editor

Ajay Shanker

Indexer

Hemangini Bari

Editorial Team Leader

Abhijeet Deobhakta

Project Team Leader

Lata Basantani

Project Coordinator

Leena Purkait

Proofreader

Laura Booth

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

About the Author

Anghel Leonard is a senior Java developer with more than 12 years of experience in Java SE, Java EE, and the related frameworks. He wrote and published more than 20 articles about Java technologies and more than 100 tips and tricks. Also, he wrote two books about XML and Java (one for beginners and one for advanced). In this time, he developed web applications using the latest technologies on the market. In the past two years he has been focused on developing RIA projects for GIS fields. He is interested to bring onto the Web as much desktop as possible, therefore GIS applications represent a real challenge for him.

I want to thank my family, especially my wife.

About the Reviewers

Joseph Edem Morny has been involved in Enterprise Java technologies since he got introduced to Java in 2005, using open source tools and technologies like JBoss AS and JBoss Seam. His favourite web framework is Seam, which he has been using since its pre 1.5 days.

He has been an active promoter of Java EE and Seam, organizing workshops and seminars on university campuses where he worked as a teaching assistant, and on a national scale at Ghana's foremost institution of IT, Kofi Annan Centre for IT Excellence. Edem holds a Bsc Computer Science from KNUST in Ghana. He is also a SCJP, SCWCD and SCBCD.

Edem is a senior developer at the application development center in Accra, Ghana of an international biometric security solutions company, leading thedevelopment of Biocryptic Identity Management Systems for the global market.

Peter Johnson has been working in information technology since 1980, starting with mainframes, then to Solaris, then Windows, and now also on Linux. In the 90s, he developed using C++ and for the last 9 years has been working with Java. He works in a team that evaluates open source software for inclusion in an open source stack that is offered on Unisys and other hardware. In addition, he spends a lot of time on performance tuning and speaks regularly on that topic at various international conferences, such as the Computer Measurement Group Conference, JBoss World and Linux World. Peter is also currently co-authoring a book on JBoss Application Server, and is a JBoss committer and frequent JBoss forum contributor.

Preface

This book will show you how to develop a set of Java projects using a variety of technologies and scenarios. Everything is described through the "eyes" of JBoss Tools.

After we settle on the project (or scenario) that will be developed, we will configure the proper environment for the current tool (those projects selected will cover between them the main components of a web application in terms of the backstage technology). We continue by exploring the tool for accomplishing our tasks and developing the project's components. A cocktail of images, theoretical aspects, source codes, and step-by-step examples will offer you a thoroughgoing for every tool. At the end, the project will be deployed and tested. In addition, every chapter is "lard" with pure notions about the underlying technology, which will initiate you into, or remind you of, the basic aspects of it.

This book will show you complete and functional applications, and will familiarize you with the main aspects of every tool. By the end you will have been provided with sufficient information to successfully handle your own projects through JBoss Tools.

What this book covers

Chapter 1 is a compressive chapter that will help you discover the features brought by the new JBoss Tools 3.0. The main goal of this chapter is to make an introduction to what will follow in the next chapters and to "wake up" your curiosity. In addition, the reader can see different possibilities of installing JBoss Tools on different platforms and for different goals.

Chapter 2 teaches you how to use Eclipse and JBoss AS in a symbiotic manner. In this chapter you will see how to use the JBoss AS Tools to configure, start, stop and monitor the JBoss AS directly from Eclipse IDE. Also, you can see how to create and deploy new projects.

Chapter 3 is a collection of tag-components from different technologies as Ajax, JSF, RichFaces, Seam, and so on. Because the components are built on the drag-and-drop technique, this tool is very easy to use, especially when you need a fast method for generating tags into JSP pages. This chapter will cover—with description and examples—the most important tags that can be generated through JBoss Palette. Also, the chapter will contain a section about the Palette Options.

Chapter 4 will talk about punctual framework's tools and I will start with JBoss Tools for Java Server Faces. After I present the Faces Config Editor, which is the main visual component for JSF support, I will follow the framework mains characteristics and I will discuss—from the JSF Tools perspective—about managed beans, validators, converters, navigation rules, and so on.

Chapter 5 will give you a complete cover of the graphical Struts editors that are used for generating/managing XML documents (configuration, tiles, validators). Also, you will see how to work with code generation and debug support for Struts projects. Everything will be sustained by images (captures) and examples.

Chapter 6 will show you how to accomplish the most important modules of a Seam project, like Action, Form, Entity, and so on through the Seam Tools filter in the first part. Later, in the second part of the chapter, you will work with the visual editors dedicated to increasing the speed of developing/controlling Seam components.

Chapter 7 will show some advanced skills, like Hibernate and Ant, generation of POJOs, debugging goals and reverse engineering control after a detailed presentation of how to use Hibernate Tools to speed up the configuration and mapping tasks.

Chapter 8 will discuss about the jBPM Tools. You will see how to develop and test a complete jBPM project.

Chapter 9 will detail the main concepts of JBossESB Services, and you will see how to use ESB Tools to develop such a Service.

Chapter 10 will help you create from scratch a WSDL document using WSDL Editor. You will generate a complete web service from a WSDL document and from a Java bean using WS Tools wizards, and you will publish a web service using jUDDI and Web Services Explorer. In addition, you will see how to generate a web service's client, how to test a web service through Web Services Explorer, how to convert WSDL documents to WSIL documents and how to inspect WSDL web services through WSIL and WSE.

Chapter 11 will work with the Portal Tools. You will see how to use the wizards for creating projects with Portlet Facets, creating the Java Portlet wizard and creating the JSF/Seam Portlet wizard.

What you need for this book

As different software products are involved in this book, it is pretty hard to recommend a list of system requirements and operating systems. Nevertheless, we have developed this book using the following specifications (use this configuration as a mark):

Mobile AMD Sempron (tm)Processor 3400+789MHz, 896 MB of RAMPhysical Address Extension.

Following are the software requirements for this book:

Microsoft Windows XP Professional Version 2002 Service Pack 2 (or any other supported operating system)Java 5 and Java 6 for Windows (or your operating system)

Rest of software, such as Eclipse, JBoss Application Server and so on, will be installed through the book.

Who this book is for

This book is recommended to Java developers that use at least one of the covered technologies (JSF, Struts, Hibernate, Seam and so on). This book is for all Java developers who are looking for a unitary and powerful tool, especially designed for increasing the speed of developing, and for improving the quality of, Java web applications.

No matter how much, or how little, experience you have, developers of all levels will benefit as your use of JBoss Tools is directly proportional to the complexity of your application. Since JBoss Tools covers all level of experience, you may use it at your own level for your own applications, without involving unnecessary features. All you have to be familiar with is Eclipse environment, Java core, and you must have some expertise in the technology for which you want to use the JBoss Tools. Basic expertise for each technology is provided in the book, but for more complete and detailed aspects you should read dedicated specifications, tutorials, and articles.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to <[email protected]>, and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note via the SUGGEST A TITLE form on www.packtpub.com, or send an email to <[email protected]>.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/6149_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve the subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately, so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of this book, and we will do our best to address it.

Chapter 1. An overview of JBoss Tools

As you probably know, JBoss Tools are a set of Eclipse plug-ins that offer support for developing, deploying, and testing applications based on JBoss.org (http://www.jboss.org/) projects.

If this definition doesn't say much, then let's just say that JBoss Tools is an "all-in-one" product that provides complete support for developing Java SE and Java EE applications. Also, it's important to note that JBoss Tools can sustain the development of each tier of an enterprise/desktop application by providing dedicated components like editors, wizards, syntax-highlighting, import/export skills, code completion, refactoring, etc.

If you are familiar with the JBoss Tools evolution, then it is impossible to skip the fact that the new JBoss Tools 3 Candidate Release 2 (JBoss Tools 3.0.0 CR2) version is the "king" of all versions. But, if JBoss Tools is a new challenge for you, then try to be careful; JBoss Tools creates dependency and it seems that the current software market doesn't offer an antidote yet. This compelling superiority is because JBoss Tools provides tools for both standard J2SE/J2EE technologies like EJB3 and JPA as well as open source technologies that have become widely accepted in enterprise Java development, for example, Hibernate, JBPM, Seam, etc. It brings everything that you'll ever need—together!

Looking inside the 3.0.0 CR2 bundle, we see the following tools (this is just a brief overview meant to reveal the JBoss Tools covered technologies):

JBoss AS Tools: To manage application servers (especially for JBoss AS)JBoss JSF Tools: Tools dedicated to supporting JSF/JSF-related technologiesJBoss Struts Tools: Tools dedicated to the Struts frameworkJBoss Seam Tools: Tools dedicated to Seam projectsJBoss Hibernate Tools: Tools dedicated to the Hibernate frameworkJBoss jBPM Tools: Tools to design and deploy jBPM business processesJBossWS Tools: WTP Tooling for JBoss Web ServicesPortlet Tools: Tooling for PortletsJBoss ESB Tools: Tools to develop ESB componentsJBoss XDoclet Tools: Tools to integrate XDoclet in EclipseJBoss Freemarker IDE: Syntax-highlighting editor for Freemarker filesJBoss RichFaces VPE: Visual Page editor for Richfaces, JSF, HTML, and CSSBIRT Tools: Reporting Tooling for JBoss J2EE Servers (not presented in this book)JBoss Smooks: Tooling Tools for Smooks (not presented in this book)

Next, in this chapter, you will see a brief listing of the features of JBoss Tools and after that we will proceed to install and configure the 3.0.0 CR2 release.

Further, in the following chapters, we will discuss the main tools and see that JBoss Tools can be a complete solution for Java developers.

What's new in JBoss Tools 3?

To amaze its fans and win new ones, JBoss Tools comes with a long list of bug fixes and very important add-ons, like Seam 2, JBossWS, and Mac OS X support. Based on new features and the finest interactivity, JBoss Tools give us a strong feeling of control and robustness.

Here is a short list of the JBoss Tools features. These are the "checkpoints" in JBoss Tools evolution from its first release until version 3.0.0 CR2:

Seam Tools:
Change Seam parent projectEasier view-id selectionSeam pages editor preferencesSeam Ear project validatorSeam project settings validatorSeam components/ELSub classes/inner classes
Hibernate Tools:
Console configuration created for JPA projectExport diagramQuery editorCode completion for Hibernate configuration propertieshbm.xml and cfg.xml editor
JBoss AS Tools:
Drag-and-drop to JBoss Server View"Explore" shortcut in Server ViewMore strict server launchesJBoss AS 5 supportJMX Console
JBoss ESB Tools:
XSDjboss-esb.xml editor
VPE:
Richfaces 3.3Restore Default for PaletteTabbed Page Design Option dialogNew CSS Dialog performanceFolding in source editorMemory tuningTLD Version supportXUL Runner

Note

For a complete list of the JBoss Tools features, please check the http://docs.jboss.org/tools/whatsnew/ features page.

"Pretty impressive!" you may say! Well, the above list was just a brief overview of the JBoss Tools features. It is only when put under a microscope that every individual JBoss tool reveals its real power. So, what are we waiting for? Let's install it!

Installing JBoss Tools

Installing JBoss Tools is a straightforward process that can be accomplished in multiple ways. Next, you will see two of the most secure and used methods for installing JBoss Tools on the supported platforms.

Installing Eclipse version 3.4.x (Eclipse Ganymede)

It is obvious that before installing JBoss Tools, you will need to download and install the Eclipse IDE. For getting the best results in a short time, it is recommended to use Eclipse version 3.4.x (we downloaded the Eclipse 3.4.1—component of Eclipse Ganymede Packages) and the embedded WTP version. The quickest way to get this is to download the Eclipse IDE for Java EE Developers, which is available at http://www.eclipse.org/downloads/ for three platforms: Windows, Linux, and Mac OS X. Notice that for all the platforms, the Eclipse IDE for Java EE Developers requires at least Java 5.

Note

In this book, we have used the Eclipse IDE version 3.4.1 and the embedded WTP, which was the latest stable release when this book was written. In addition to this, the examples were developed and tested on Windows XP operating system.

Uaually Eclipse is provided as a ZIP/RAR archive that should be unzipped in your favorite location. Afterwards, the Eclipse can be launched through eclipse.exe executable file. Anyway, for troubleshooting, you have a detailed documentation of Eclipse at http://help.eclipse.org/ganymede/index.jsp.

Installing JBoss Tools through Eclipse software updates

The quickest and simplest way to install the JBoss Tools consists of using a great facility of Eclipse, named Software Updates. This is a graphical wizard that will guide you through the search/install process of the latest plug-ins/add-ons for Eclipse. For installing JBoss Tools, you can use this wizard as follows:

Launch the Eclipse IDE.From the Help menu, select Software Updates.Switch to the Available Software tab.Click on the Manage Sites button.Click on the the Add button and type http://download.jboss.org/jbosstools/updates/development in the Add Site window—if it is already listed, make sure it is enabled (checked).

Note

The JBoss Tools update sites are:

Stable Updates: download.jboss.org/jbosstools/ updates/stable.Development Updates: download.jboss.org/jbosstools/ updates/development.Nightly Updates: download.jboss.org/jbosstools/ updates/nightly/trunk.
Return to the previous wizard and expand the newly added node (left-panel)—this is the checkbox especially created for http://download.jboss.org/jbosstools/updates/development resource. Wait for Eclipse to pending this resource. When the pending ends, you should see a list of checkboxes (one for each JBoss Tools component) under the resource node.For this book, it is recommended to download and install the entire package of tools by selecting all the corresponding checkboxes. Note that in case you want to install only a subset of tools, you have to keep in mind the dependencies between standalone plug-ins (a diagram of dependencies between the most used plug-ins is in the first figure). After you decide what tools to install, just click on the Install button and follow the wizard instructions.

Any error/warning/info that occurs while download/install is in progress will be reported in the Problems view or in installation wizard pages. This Problems view will appear automatically when the download process begins and in the best case, it will remain empty during the download/install process (as shown in the following screenshot).

A common error while installing JBoss Tools 3 under Eclipse 3.4, appears in the installation wizard after we click on the Install button. These errors are about invalid jars or missing dependencies. To be precise, the message error is something like this: Unable to satisfy dependency from org.eclipse.birt.report.viewer.... Fixing this error can be done by the following steps:

Cancel current operation, close and reopen the Software Updates wizard.Use the Manage Site button to add two more sites, as follows (if they already exist, then just check them): http://download.eclipse.org/birt/update-site/2.3/ and http://download.eclipse.org/releases/ganymede/. Check these two entries in the Available Software Sites wizard, and click the OK button.Returning to the main wizard page, make sure that all checkboxes are deselected and click on the Refresh button.Wait until the refresh is accomplished, then mark as selected the checkbox corresponding to http://download.jboss.org/jbosstools/updates/development. After pending ends, select all under-checkboxes and click on the Install button. This time you should not get any errors.

Manual installation of JBoss Tools

If you want to get more involved in the installation process, then you can choose to "manually" download and install JBoss Tools. This is a three-step process as follows:

To start, you have to download the JBoss Tools according to your platform (Windows/x86, Linux/GTK/x86, Linux/GTK/x86_64, Mac OS X Carbon/Universal) from the http://www.jboss.org/tools/download/index.html address (or this link: http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=242269).

Note

You can download a bundle of all the JBoss Tools plug-ins (recommended for this book) or you can download a subset of tools. In case of downloading a subset of tools, you have to keep in mind the dependencies between standalone plug-ins (shown in the previous figure).

Next, unzip the files into your eclipse plugins/features directory, and restart Eclipse with the -clean option, like this:
eclipse –clean
When Eclipse restarts, the new features will be ready to serve you! To check if something was installed, try the New | Other option in the File menu. In the projects type list, you should see new entries like Hibernate, Web Services, ESB and so on. These appear because you just successfully installed JBoss Tools.

Summary

In this chapter, we learnt some basic notions about the JBoss Tools package. Also, we saw how to download and install JBoss Tools as a bundle or as a sub-set.

Being an introduction to JBoss Tools, we focused on covering the main questions about JBoss Tools, like "What is it good for?", "What exactly is contained in the JBoss Tools package?", "What is the latest stable version?", "Can I see some features?", "Can I install it on my machine?", and so on.

Chapter 2. JBoss AS Tools

In this chapter, we will discuss the main steps that will offer us a functional environment for developing, running, and testing J2EE applications by using the Eclipse IDE, JBoss Tools, and a J2EE Application Server. The first and one of the most important things is to understand how to connect a J2EE Application Server with the Eclipse IDE, through the JBoss AS plug-in. After you successfully accomplish this task, we will see a brief description of creating and deploying J2EE applications on the chosen server.

Note

In this book, we recommend that you to 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 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):

From the Window menu, select Preferences.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).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.

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.

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.

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.

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

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.

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:

From the File menu, select the New | Other... option.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.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.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.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).

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.

JBoss AS Perspective

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 ViewProject Archives ViewConsole ViewProperties 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).

Note

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 following screenshot)Publishing: Allows you to see if changes are being updatedRepublish: Allows you to see if changes are waiting

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

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

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