31,19 €
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:
Seitenzahl: 381
Veröffentlichungsjahr: 2009
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]>)
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
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.
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.
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.
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.
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):
Following are the software requirements for this book:
Rest of software, such as Eclipse, JBoss Application Server and so on, will be installed through the book.
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.
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.
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.
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.
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 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.
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.
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):
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.
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:
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 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.
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.
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.
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:
The JBoss Tools update sites are:
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:
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:
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).
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.
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.
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 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.
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):
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.
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: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.
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:
The new server was added! Just restart the Eclipse IDE.
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 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.
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:
For launching the JBoss AS Perspective (or any other perspective), follow these two simple steps:
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.
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.
The simplest ways to start our JBoss AS server are:
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.
The simplest ways to stop JBoss AS server are:
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.
Beside Start and Stop operations, JBoss Server View allows us to:
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.
A server may have one of the following statuses:
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:
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).
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:
This category is focused on working with XML descriptors files. It has a default Ports subcategory that fills up the Properties