Red Hat JBoss Developer Studio 6.0 Beginners Guide

Red Hat JBoss Developer Studio 6.0 Beginners Guide
Red Hat JBoss Developer Studio
6.0
Beginners Guide
Provides information about the use of the JBoss Developer Studio from
a beginners level.
Edition 6.0.0
Isaac Rooskov
Red Hat JBoss Developer Studio 6.0 Beginners Guide
Provides information about the use of the JBoss Developer Studio from
a beginners level.
Edition 6.0.0
Isaac Ro o sko v
iro o sko [email protected] m
Edited by
Andrew Ro ss
anro [email protected] m
Max Andersen
[email protected] m
Legal Notice
Copyright © 2011 Red Hat.
T his document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported
License. If you distribute this document, or a modified version of it, you must provide attribution to Red
Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be
removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section
4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo,
and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux ® is the registered trademark of Linus T orvalds in the United States and other countries.
Java ® is a registered trademark of Oracle and/or its affiliates.
XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States
and/or other countries.
MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other
countries.
Node.js ® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or
endorsed by the official Joyent Node.js open source or commercial project.
T he OpenStack ® Word Mark and OpenStack Logo are either registered trademarks/service marks or
trademarks/service marks of the OpenStack Foundation, in the United States and other countries and
are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or
sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Abstract
T he Beginners Guide brings all concepts pertaining to the JBoss Developer Studio back to basics. It is
intended for individuals who may be new to application servers and the creation of applications for
deployment.
Table of Contents
Table of Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . .
Preface
. . . . . . . . . 1.
Chapter
. . .Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . .
.Chapter
. . . . . . . . 2.
. . .T. he
. . . interface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . .
2.1. JBoss Developer Studio
5
2.2. JBoss Central
6
2.3. Setting up a JBoss server
7
2.3.1. Adding a new application server for use with the JBoss Developer Studio
7
2.3.2. Using the JBoss application server with the JBoss Developer Studio
8
.Chapter
. . . . . . . . 3.
. . .Java
. . . . . Web
. . . . . (EE)
. . . . .and
. . . . Standard
. . . . . . . . . . .Edition
. . . . . . . (SE)
. . . . . Plug-Ins
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
............
3.1. Visual Web T ools
11
3.2. Seam Development T ools
14
3.3. Hibernate T ools
18
3.4. Portal T ools
19
3.5. JMX T ools
21
3.6. JSF T ools
22
3.7. JBoss AS T ools
24
3.8. Archive T ools
24
.Chapter
........4
. ...Workshops
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
............
4.1. REST Easy
26
4.2. Seam
38
. . . . . . . . . 5.
Chapter
. . .Where
. . . . . . .to
. . .go
. . .from
. . . . .here
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
...........
.Getting
. . . . . . . .Help
. . . . .and
. . . . Giving
. . . . . . . .Feedback
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4. .0. . . . . . . . . .
A.1. Do You Need Help?
40
A.2. Give us Feedback
40
. . . . . . . . . .History
Revision
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4. .1. . . . . . . . . .
1
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
2
Preface
Preface
T his manual uses several conventions to highlight certain words and phrases and draw attention to
specific pieces of information. T o get more information on these conventions please refer to the
Docum ent Conventions manual, which can be found on the Red Hat Documentation website under
the JBoss Developer Studio section.
3
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Chapter 1. Introduction
T he JBoss Developer Studio is an Integrated Development Environment (IDE) that includes JBoss
T ools and assists with the development of applications and services on JBoss Middleware software.
T hese tools have been developed and are used by developers for increased efficiency and productivity
with JBoss software.
T his guide covers the basics of the interface you will be working with and the tools within it, assuming as
little knowledge on your side as possible. If you are not familiar with JBoss Developer Studio then this
guide is the best place to begin.
4
Chapter 2. The interface
Chapter 2. The interface
T his chapter discusses the interface to the JBoss Developer Studio IDE.
2.1. JBoss Developer Studio
Providing a container for all development work performed with JBoss Developer Studio allows for
control over the application server, the applications on it and the interface through which you can
develop your own applications.
Start JBoss Developer Studio by double-clicking on the jbdevstudio executable in your installation
directory.
Following this you will be asked to specify a workspace. A workspace is the location on your computer
where your project files will be stored. If you wish to change your workspace location after this step you
can do so by selecting File → Switch Workspace → Other....
Figure 2.1. Workspace launcher
After selecting the location of the workspace, you will be greeted with the Welcom e screen and a button
that will take you to JBoss Central and your workbench.
5
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 2.2. Welcome screen
2.2. JBoss Central
When starting JBoss Developer Studio you will see JBoss Central in the workspace. From JBoss
Central you can quickly Create Projects, run Project Exam ples, view Docum entation, read
the latest News and Blogs, and change JBoss Central Settings.
6
Chapter 2. The interface
Figure 2.3. JBoss Central
For further information on JBoss Central see the Getting Started Guide for this realease.
2.3. Setting up a JBoss server
T he JBoss Enterprise Application Server provides the full range of Java EE 5 features as well as
extended enterprise services including clustering, caching, and persistence.
2.3.1. Adding a new application server for use with the JBoss Developer Studio
T o add a new server runtime follow these steps:
1. From your workbench, click on Window → Preferences → Server → Runtime Environments.
2. Click on the Add... button.
3. Select the runtime environment type of your application server from the list provided.
4. T ick the box for the Create a new local server option.
5. Click on the Next > button.
6. Provide a name for your server runtime and then click on the Browse... button, next to the Hom e
Directory location space.
7. Navigate to the directory where the server you wish to add is installed and click on the OK button.
8. Select the Java Runtime Environment (JRE) you wish to use for this server from the drop-down
menu. If the required JRE is not listed, click on the JRE button beside the list, click the Add...
button in the Installed JREs Preferences dialog box, and follow the prompts to install the
correct JRE.
9. T he Configuration section should automatically list the profiles available for your server.
Select the server configuration you wish to use by clicking on its name in the list.
If the profile you wish to use is not listed click on the Browse... button, navigate to the profile
7
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
location and click the OK button.
10. If all the information is correct click the Finish button.
If you need to change any information click the < Back button until you reach the screen with the
information that needs to be altered and then navigate back to the JBoss RunT im e screen and
click the Finish button.
Once the new sever has been added, you can select it for use by clicking on its name in the Server
Runtim e Environm ent list and then clicking the OK button, which will then take you back to the main
interface.
T o start your new server, select it from those available in the Servers view and click the button
displaying a white arrow in a green circle.
Note
If the Servers view is not displayed at the bottom of your Workbench, you can activate it through
Window → Show View → Other → Server → JBoss Server View and then click the OK
button.
2.3.2. Using the JBoss application server with the JBoss Developer Studio
T he JBoss Application Server can be started by selecting it in the Servers view, which can be found in
the lower part of the window, and then clicking the green arrow to the right.
Figure 2.4 . Starting and stopping the server
After the server has been successfully started the status field next to the server name will change from
Stopped to Started, Synchronized.
Figure 2.5. Server started successfully
Once the server has started, double click on the server name to see an Overview screen.
8
Chapter 2. The interface
Figure 2.6. JBoss Application Server overview
T he Overview section contains the subsections: General Inform ation, Managem ent Login
Credentials, Server Behaviour, Publishing, T im eouts, Application Reload
Behavior, Server State Detectors and Server Ports.
T he General Inform ation subsection allows you to change the value for the Server nam e and
Host nam e. By clicking on the Runtim e Environm ent label a dialog box will be shown with options
to change the name of the server runtime, the home directory, the Java Runtime and the server
configuration that will be used when running the application server. T he Open launch
configuration button displays a dialog box that allows you to configure the technical details of the
application server instance.
Below the General Inform ation subsection is the Managem ent Login Credentials
subsection. Here you can set the User Nam e and Password that will be used to provide secure
access to your server.
T he last subsection on the left is dedicated to Server Behaviour. T his section allows you to specify
how JBoss Developer Studio should interact with the server and whether it is local or remote.
T he Publishing subsection at the top right of the Overview section allows you to specify when
applications will be published to the location specified (whether the applications will be made available
through the application server depends on the server running and if it is configured to recognize
dynamic changes). You can select to either never have an application be published automatically or for a
check of new applications yet to be published to occur at a certain timed interval.
T he T im eouts subsection below the Publishing subsections allows you to set the start and stop
times (in seconds) in which the server should complete all of its operations. T his setting is made
available in order to decrease the chance of the server freezing or hanging.
T he Application Reload Behavior subsection allows you to specify how and when applications
associated with the server, are reloaded.
Below the Application Reload Behavior subsection is the Server State Detectors
9
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
subsection. A server poller gathers information about the server at certain points in time, capturing
information about processes and applications. T his section allows you to select the pollers to be used
during server startup and shutdown.
T he final subsection is called Server Ports, below the Server Polling subsection. T his section
allows you to alter the port numbers that the server pollers gather their information from. T he two
settings JNDI Port and Web Port are set to be automatically detected by default; normally there
should be no reason to manually select the port numbers.
Note
Changing the Server Ports subsection configuration will not alter which ports the server itself
listens on.
T he default address of the server is http://localhost:8080, which you can type into your Internet
browsers address bar.
Figure 2.7. Server access
Refer to the JBoss Server Manager guide for further details.
10
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
T his chapter provides details on the Java plug-ins that are included in JBoss Developer Studio.
3.1. Visual Web Tools
Visual Web T ools aids in the development of web pages and web projects.
Visual Page Editor
T he Visual Page Editor allows an application to be developed in conjunction with a real time
visual preview. T he application can be viewed either as the source code, as a preview of the
application, or both simultaneously in a split-screen presentation. T he Visual Page Editor can
be used for developing an application using technologies such as JavaServer Faces (JSF),
JavaServer Pages (JSP), Struts, and Hypertext Markup Language (HT ML). T he Visual Page
Editor also features a graphical toolbar for in-line styling.
Figure 3.1. Visual Page Editor
Refer to the Editors chapter of Visual Web Tools Reference Guide for more details.
JBoss T ools Palette
T he JBoss T ools Palette provides access to a library of tags used when creating JSP and JSF
pages. T ags can be quickly inserted into pages from a number of libraries including:
11
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
HT ML
JBoss
JSF
JST L (JSP Standard T ag Library)
MyFaces
Oracle ADF (Application Development Framework) Faces
Struts
XHT ML (Extensible Hypertext Markup Language)
Custom-made tags and third-party tag libraries can also be included in the JBoss T ools Palette.
Figure 3.2. JBoss T ools Palette
Refer to the JBoss T ools Palette chapter of the Visual Web Tools Reference Guide for more
details.
Web Projects View
T he Web Projects View is an additional view. It enhances project authoring with a number of
features including:
Project artifacts for JSF and Struts projects are organized by function, allowing for better
project visualization.
Selected items can be dragged and dropped into JSP and other JSF compatible pages
including:
JSF managed bean attributes.
JSF navigation rule outcomes.
Property file values.
T ag library files.
T ags from tag libraries.
12
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
JSP page links.
JSF and Struts projects can be quickly created or imported from the shortcut buttons.
T ag library files can be expanded, inspected, and easily added to the JBoss T ools Palette.
Figure 3.3. Web Projects View for JSF (left) and Struts (right) projects
Refer to the Web Projects View chapter of the Visual Web Tools Reference Guide for more
details.
OpenOn
OpenOn provides an easy method for switching directly from one project resource to another
without navigating through the Package Explorer view. Pressing F3 or Ctrl+click when a
reference to another file is highlighted will open the file in the editor.
Refer to the Editors chapter of the Visual Web Tools Reference Guide for more details.
Content Assist
Content Assist displays context-specific code completion suggestions while typing, speeding up
development and reducing typing errors. Content Assist is supported in the following contexts:
T he suggestion list can be displayed by pressing Ctrl+Space, and the highlighted entry can
be selected and inserted by pressing Enter.
13
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 3.4 . Content Assist
Refer to the Editors chapter of Visual Web Tools Reference Guide for full details.
Drag-and-Drop
Properties, managed bean attributes, navigation rules, tag library file declarations, and JSP
pages can all be dragged from the Web Projects view and dropped into the editor to add
content.
Refer to the Web Projects View chapter of the Visual Web Tools Reference Guide for more
details.
RichFaces Support
RichFaces and Ajax4jsf tag libraries can be used from the JBoss T ools Palette, and RichFaces
components are rendered in the Visual Page Editor.
Refer to the Editors chapter of the Visual Web Tools Reference Guide for more details.
3.2. Seam Development Tools
JBoss Seam combines several technologies to reduce the complexity of developing modern Web 2.0
applications including:
Enterprise Java Beans (EJB3).
JavaServer Faces (JSF).
Asynchronous JavaScript and XML (Ajax).
Java Portlets.
Business Process Management (BPM).
Seam provides an interface to these different technologies through simple Plain Old Java Objects
(POJO), user interface components, and XML. Seam does not distinguish between presentation-tier
components and business logic components in an effort to present a simple, unified component model
for the Java Enterprise Edition platform. Seam also provides mechanisms to manage application states
14
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
across multiple workspaces, methods to manage workflow and pageflow through jBPM, and
comprehensive integrated testing features.
T he Seam Development T ools in JBoss Developer Studio allow for easy Seam application
development with a number of features including:
New Seam Project wizard
T he New Seam Project wizard allows the details of the Seam project to be configured, including
target runtimes, target servers, project facets, and web module settings. It then generates all
the necessary files for a Seam project.
Figure 3.5. New Seam Project wizard
Other Seam wizards
Wizards are also included for creating new Seam Actions, Seam Forms, Seam Conversations,
and Seam Entities.
15
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Entity generation
Another wizard exists for generating Seam entities. T he wizard produces a set of CRUD
(create-read-update-delete) Seam components and web pages. T hese can be generated by
reverse-engineering an existing database, or by using the existing entities in the application.
Editors and views
T here are a number of editors available in JBoss Developer Studio for working with Seam in
addition to the Visual Page Editor including:
Seam Pages Editor
T he Seam Pages Editor is used for editing the pages.xm l file. T he file can be edited
through three different views:
the graphical view, which diagrammatically represents the project page-flow and
exception handling;
the tree view, which lists the elements and attributes of the pages.xm l file in a
hierarchical tree for simplified editing;
and the source view, which allows direct editing of the pages.xm l source.
Figure 3.6. Seam Pages Editor (graphical view)
16
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
Seam Components Editor
T he Seam Components Editor is used for editing the com ponents.xm l file. T he file
can be edited through two views: the tree view and the source view, which operate
similarly to the views in the Seam Pages Editor.
Figure 3.7. Seam Components Editor
T he Seam Editors implement Content Assist and OpenOn; for more details on these
technologies refer to Section 3.1, “Visual Web T ools”. Seam Editors also feature validation tools
to highlight potential issues with the application.
CRUD database applications
CRUD refers to the four basic SQL commands: create, read, update, and delete. A CRUD
database application uses forms to retrieve data from and submit data to a database.
CRUD database applications can be created through the New Seam Project wizard.
T estNG
T estNG (Testing, the Next Generation) is a Java-based unit testing framework. T estNG suites
can be added to a project through the New Seam Action wizard.
17
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Refer to the Seam Development T ools Reference Guide for more details.
3.3. Hibernate Tools
Hibernate is an object-relational mapping (ORM) library, used for mapping an object-oriented domain
model to a relational database. Hibernate also serves as a query service, allowing queries to be
expressed in native SQL (Structured Query Language), an extension of SQL named Hibernate Query
Language (HQL), or an object-oriented Criteria and Example API (Application Programming Interface).
Hibernate T ools in JBoss Developer Studio provides several features to aid in developing with
Hibernate including:
Mapping Editor
T he Mapping Editor is used for authoring Hibernate XML mapping files. It supports code
completion (Content Assist) and syntax highlighting.
Console
T he Hibernate Console provides a visual representation of database connections and class
relationships. Queries can be interactively performed on the database representation.
Figure 3.8. Hibernate Console
Reverse Engineering
Databases can be reverse-engineered to construct domain model classes, Hibernate mapping
files, annotated entity beans, HT ML documentation, or complete JBoss Seam applications.
18
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
Wizards
Wizards are included to step through procedures to generate Hibernate configuration files and
Hibernate console configurations.
Apache Ant T ask
Apache Ant is a tool for automating software build processes. Hibernate T ools includes an
Apache Ant T ask for generating schema, mapping, and Java code related to the build process.
Refer to the Hibernate T ools Reference for more details.
3.4. Portal Tools
JBoss Portal is a platform for hosting and serving the web interface of a web portal. It allows for
content management and experience customization, and supports standard portlets, single sign-ons,
clustering, and internationalization.
JBoss Portal applications can be created through the Dynamic Web Project wizard. Java portlets, JSF
portlets, and Seam portlets are all supported.
19
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 3.9. Dynamic Web Project wizard
Click the Modify... button and enable portlets for the creation of JBoss Portal applications through
this wizard.
Refer to the JBoss Portal T ools Reference Guide for more details.
20
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
3.5. JMX Tools
Java Management Extensions (JMX) is a Java tool-set for managing and monitoring applications,
connected devices, and service-oriented networks. A managed resource is represented by a dynamic
object called a Managed Bean or MBean, which is a JavaBean with a dependency injection.
T he JMX T ools consists of the MBean Explorer and the MBean Editor.
MBean Explorer
T he MBean Explorer lists a connection's Managed Beans, domains, attributes, and operations
in a hierarchical tree. Items in the tree can be filtered, expanded, and collapsed, and doubleclicking on any item will open it in the MBean Editor.
Figure 3.10. MBean Explorer
MBean Editor
T he MBean Editor is a detailed property-editor made up of four pages:
the Attributes page, which allows the attributes of the Managed Bean to be viewed and
edited.
the Operations page, which allows the operations of the Managed Bean to be viewed and
edited.
the Notifications page, which allows the Managed Bean to be subscribed to, and which
notifications are received.
21
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
the Info page, which displays information on the Managed Bean.
Figure 3.11. MBean Editor
Refer to the JMX T ools Reference Guide for more details.
3.6. JSF Tools
Java Server Faces (JSF) is a Web application framework developed by Sun Microsystems© Inc. JSF
T ools allows you to build JSF based applications, add JSF capabilities to existing web projects, import
JSF projects and choose a JSF implementation during application development.
T he tools included are outlined as follows:
Wizards that assist with the creation of new JSF and Facelets projects and adding JSF capabilities to
existing web projects.
Preconfigured templates are included, along with the ability to create your own.
Add and generate code for new managed beans and then add them to a JSF configuration file.
T he ability to create your own custom Converter and Validator.
Constant validation checking no matter how you are currently interacting with the code, which
ensures you are always aware of any errors during the development process.
T hree views are provided for interacting with the code: the Diagram view, T ree view and Source view.
Synchronization between the views ensures you are always working on the newest version.
22
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
Figure 3.12. Diagram view
Figure 3.13. T ree view
23
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 3.14 . Source view
Refer to the JSF T ools Reference Guide for more details.
3.7. JBoss AS Tools
T he JBoss AS T ools consist of a number of additional views for managing an installed JBoss Server
through the JBoss AS (Application Server) perspective. T hese additional views include the standard
Console and Properties views, and the Servers view. T he Servers view allows installed servers to be
configured, monitored, and managed.
Figure 3.15. Servers view
Refer to the JBoss Server Manager Reference Guide for more details.
3.8. Archive Tools
T he JBoss AS T ools also include the Project Archives view for streamlined packaging and archiving of
applications. Application projects can be configured with specific packaging instructions, and wizards are
included for creating and managing archives.
24
Chapter 3. Java Web (EE) and Standard Edition (SE) Plug-Ins
Figure 3.16. Archive T ools
Refer to the JBoss Server Manager Reference Guide for more details.
25
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Chapter 4. Workshops
Follow the instructions in these workshops to broaden your knowledge and understanding of JBoss
Developer Studio.
4.1. RESTEasy
In this REST Easy workshop we will provide an example of how to solve the problem of creating new
customers for an online store. T his will be achieved through the creation of a shopping application and
adding customer records through a web browser.
Prerequisites
T he following technologies are necessary for this workshop:
JBoss Developer Studio 5.0
JBoss Enterprise Application Platform 6 or JBoss Service Orientated Architecture
Platform 6
Firefox 2.0 or higher web browser
REST Client Firefox plug-in available from https://addons.mozilla.org/en-US/firefox/addon/9780
Make sure JBoss Developer Studio is open with the application server running. For simplicity it will be
assumed for the rest of the workshop that you are running the JBoss Enterprise Application
Platform 5, however the steps will be the same if you are using the JBoss Service Orientated
Architecture Platform 5.
In JBoss Developer Studio navigate to Help → Project Example.
Figure 4 .1. Project Example Menu
26
Chapter 4. Workshops
In the Project Example menu dialog box, scroll to REST Easy → REST Easy Simple Example and
click the Finish button.
Figure 4 .2. REST Easy Simple Example
T here may be two issues to fix before you can continue. T he description for these issues are T arget
runtim e JBoss 4 .2.2 Runtim e is not defined and Java com piler level does not
m atch the version of the installed Java project facet. If they do not appear skip to
Figure 4.7, “Completed fixing the issues”. If they do appear, the following steps will resolve these issues.
27
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 4 .3. Quick Fixes
T o fix the first issue with the description T arget runtim e JBoss 4 .2.2 Runtim e is not
defined click on this description and then click the Quick Fix button.
Figure 4 .4 . Fixing the first issue
T he next dialog box will display two runtime issues to fix, however by fixing the second one, labeled as
Configure T argeted Runtim es, both issues will be corrected.
Select the issue called Configure T argeted Runtim es and click the Finish button.
28
Chapter 4. Workshops
Figure 4 .5. Runtime issues
A large dialog box will open displaying a long list of property categories on the left hand side. Navigate
down to and click on the T argeted Runtimes property title. T o the right of the menu where the JBoss
4 .2.2 Runtim e box is selected, deselect it and then select the name of your JBoss Enterprise
Application Platform 5 runtime.
Once the JBoss Enterprise Application Platform 5 is selected and the old runtime deselected, click
the Apply button and then the OK button.
29
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Note
In Figure 4.6, “Selecting the correct runtime”, the runtime that will be used is the one called JBoss
EAP 5.0 Runtim e Server, though the name will depend on what you called it when you
configured the server for use with JBoss Developer Studio.
Figure 4 .6. Selecting the correct runtime
T o fix the second issue with the description Java com piler level does not m atch the
version of the installed Java project facet, click on its description and then click the
Quick Fix button.
After clicking the Quick Fix button the Java compiler issue should disappear because the JBoss
Developer Studio has made the necessary changes in the background to fix it.
30
Chapter 4. Workshops
T he Quick Fix dialog box should now be empty. Click the Finish button.
Figure 4 .7. Completed fixing the issues
T o add the project to the JBoss Enterprise Application Platform 5 server right click (or Control-click
on Mac OS) on the server name in the Servers view in the bottom section of your workbench. Click on
the Add and Remove... option.
31
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 4 .8. About to add the project to the server
From the Add and Rem ove dialog box ensure the box labeled If server is started, publish
changes im m ediately is ticked. In the left-hand menu, highlight the project you just created called
sim ple by clicking on it.
32
Chapter 4. Workshops
Figure 4 .9. Add project to server
Click the Add > button to move it from the left-hand menu labeled Available to the right-hand menu
labeled Configured. Once this is completed click the Finish button.
Your REST Easy project has now been deployed onto your server. We will now test the application by
using the REST Client plug-in within the Firefox web browser.
Open your Firefox web browser and navigate to T ools → REST Client.
33
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 4 .10. Selecting the REST Client
In the REST Client click on the Add Request Header button and type content-type for the Nam e and
application/xml for the Value. T his will ensure that the content will be consumable by the Plain Old Java
Object (POJO) service at the server.
Select POST from the Method drop-down menu, copy http://localhost:8080/simple/restservices/customers into the drop-down menu beside the Method and paste the following into the
Request Body:
<customer><first-name>Bill</first-name><last-name>Burke</last-name><street>256
Clarendon
Street</street><city>Boston</city><state>MA</state><zip>02115</zip><country>USA</c
ountry></customer>
T he XML for the Request Body must not contain any spaces between XML tags to avoid exceptions
occurring at the server end.
Click the Send button to add the customer information.
34
Chapter 4. Workshops
Figure 4 .11. Adding a customer
T o ensure the customer details were added, change the Method type to GET and the URL address to
http://localhost:8080/simple/rest-services/customers/1. T he /1 is added to the URL to select the
customer with the custom er id of 1, since that is the number that was given to the customer.
Click the Send button to retrieve the information. Select the Response Body tab beneath the Request
Body section to view the returned information.
35
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 4 .12. Retrieving customer information
We have added a customer and retrieved their information; now we will update their information. T o
achieve this change the Method to PUT and copy the following into the Request Body (overwriting
anything that may be in the Request Body already):
<customer><first-name>Gary</first-name><last-name>Lamperillo</lastname><street>256 Clarendon
Street</street><city>Venice</city><state>CA</state><zip>90291</zip><country>USA</c
ountry></customer>
Remember to make sure there are no spaces between the XML tags when you copy the information into
the Request Body.
Check to make sure the URL still reads http://localhost:8080/simple/rest-services/customers/1 from
when you retrieved the customer information. By using the URL that references the ID of the customer
you are updating that customer's record.
Click the Send button to update the information.
36
Chapter 4. Workshops
Figure 4 .13. Updating customer information
T o verify that the record has been updated change the Method type to GET , ensure the URL still
references customer ID 1 and click the Send button.
Select the Response Body tab beneath the Request Body section to view the returned information.
37
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Figure 4 .14 . Retrieving updated customer information
T he REST Easy workshop is now complete.
4.2. Seam
T he JBoss Enterprise Application Platform book titled the Seam Reference Guide contains an
example of how to setup Seam for use with JBoss Developer Studio.
38
Chapter 5. Where to go from here
Chapter 5. Where to go from here
For documentation on the plug-ins available as part of the JBoss Developer Studio visit
http://www.redhat.com/docs/en-US/JBoss_Developer_Studio/.
For documentation about the JBoss Enterprise Application Platform visit http://www.redhat.com/docs/enUS/JBoss_Enterprise_Application_Platform/.
For information pertaining to Eclipse visit http://www.eclipse.org/.
39
Red Hat JBoss D eveloper Studio 6.0 Beginners Guide
Getting Help and Giving Feedback
A.1. Do You Need Help?
If you experience difficulty with a procedure described in this documentation, visit the Red Hat Customer
Portal at http://access.redhat.com. T hrough the customer portal, you can:
search or browse through a knowledgebase of technical support articles about Red Hat products.
submit a support case to Red Hat Global Support Services (GSS).
access other product documentation.
Red Hat also hosts a large number of electronic mailing lists for discussion of Red Hat software and
technology. You can find a list of publicly available mailing lists at https://www.redhat.com/mailman/listinfo.
Click on the name of any mailing list to subscribe to that list or to access the list archives.
A.2. Give us Feedback
If you find a typographical error, or know how this guide can be improved, we would love to hear from
you. Submit a report in Bugzilla against the product JBoss Developer Studio and the component
Beginners Guide. T he following link will take you to a pre-filled bug report for this product:
http://bugzilla.redhat.com/.
Fill out the following template in Bugzilla's Description field. Be as specific as possible when
describing the issue; this will help ensure that we can fix it quickly.
Document URL:
Section Number and Name:
Describe the issue:
Suggestions for improvement:
Additional information:
Be sure to give us your name so that you can receive full credit for reporting the issue.
40
Revision History
Revision History
Revision 6.0.1-1.4 06
Rebuild with Publican 4.0.0
T ue Jan 7 2014
Rüdiger Landmann
Revision 6.0.1-1
Mon Aug 05 2013
Michelle Murray
T OOLSDOC-382: Rebuilt for Customre Portal, content unchanged
Revision 2-1
Wed Jul 04 2012
Major updates and restructuring
Isaac Rooskov
Revision 1-2
Review and editing
Wed Jan 12 2011
Matthew Casperson
Revision 1-1
Review and editing
Mon Feb 22 2010
Isaac Rooskov
Revision 1-0
T hu Nov 26 2009
Initial creation of book by publican
Isaac Rooskov
41
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement