Book Image

Advanced Java EE Development with WildFly

By : Deepak Vohra
Book Image

Advanced Java EE Development with WildFly

By: Deepak Vohra

Overview of this book

<p>This book starts with an introduction to EJB 3 and how to set up the environment, including the configuration of a MySQL database for use with WildFly. We will then develop object-relational mapping with Hibernate 4, build and package the application with Maven, and then deploy it in&nbsp;WildFly 8.1, followed by a demonstration of the use of Facelets in a web application.</p> <p>Moving on from that, we will create an Ajax application in the Eclipse IDE, compile and package it using Maven, and run the web application on WildFly 8.1 with a MySQL database. In the final leg of this book, we will discuss support for generating and parsing JSON with WildFly 8.1.</p>
Table of Contents (18 chapters)
Advanced Java EE Development with WildFly
Credits
About the Author
About the Reviewers
www.PacktPub.com
Disclaimer
Preface
Index

Preface

WildFly is the new name for JBoss Application Server (JBoss AS) starting with version 8.0.0. WildFly provides high startup speed, low memory overhead, a high-performance, scalable web server, customizable runtime based on pluggable subsystems, and support for Java EE 7 and the latest web development standards. In past references to the server, "JBoss" is still used, but for subsequent references, "WildFly" is used. According to the Developer Productivity Report 2012, referred to subsequently as the "2012 report", JBoss is the most commonly used application server, with 28 percent of Java developers or organizations using the application server, more than any other application server. The same report indicated that 67 percent of Java developers use the Maven build tool, more than any other build tool. Eclipse is used by 68 percent of Java developers. The Java Tools and Technologies Landscape for 2014 report (referred to subsequently as the "2014 report") indicates that JBoss is the most commonly used application server in both development (16 percent) and production (17 percent). In the book, we discuss developing Java EE applications using WildFly 8.1.0, Maven 3, and Eclipse IDE. The book combines the most commonly used tools for Java EE development: WildFly, Maven, and Eclipse IDE.

The book is based on the Java EE standards 5, 6, and 7. We will discuss the commonly used technologies and frameworks JAX-RS 1.1, JSF 2.0, JPA 2.0, JAX-WS 2.2, EJB 3.0, Hibernate 4, Ajax, GWT 2.4, and Spring 3.1. The new Java EE7 support for JAX-RS 2.0 is discussed with RESTEasy. The new Java EE 7 feature for processing JSON is also discussed.

While several books on WildFly administration are available, none on Java EE application development with WildFly are available. WildFly is the most commonly used application server with support for all the commonly used Java EE technologies and frameworks. WildFly is efficient, lightweight, and modular, and provides a flexible deployment structure. JBoss Tools provides a set of plugins with support for WildFly, Maven, and Java EE frameworks such as JSF. Maven is the most commonly used build tool for compiling and packaging a Java EE application based on a project-object model (POM). Maven provides dependency management. The Eclipse IDE for Java EE developers is the most commonly used Java EE IDE.

The objective of the book is to discuss how a Java EE developer would develop applications with WildFly using Maven as the build tool and Eclipse IDE as the development environment. The book covers all aspects of application development, including the following topics:

  • Setting the environment for an application

  • Creating sample data

  • Running a sample application

What this book covers

In Chapter 1, Getting Started with EJB 3.x, we discuss developing an EJB 3.0/JPA-based application with WildFly 8.1.0. According to the 2012 report, JPA (at 44 percent) and EJB 3.0 (at 23 percent) are the two most commonly used Java EE standards.

In Chapter 2, Developing Object/Relational Mapping with Hibernate 4, we discuss using Hibernate 4 with WildFly 8.1.0. According to the 2012 report, Hibernate (at 54 percent) is one of the most commonly used application frameworks. According to the 2014 report, Hibernate (at 67.5 percent) is the top object/relational mapping framework.

In Chapter 3, Developing JSF 2.x Facelets, we discuss using JSF 2.0 with WildFly 8.1.0. According to the 2012 report, JSF (at 23 percent) is the second most commonly used web framework. According to the 2014 report also, JSF is ranked second (at 21 percent) among "web frameworks in use".

In Chapter 4, Using Ajax, we discuss developing an Ajax application with WildFly 8.1.0. Ajax is a trend started in 2004-2005 that makes use of a web technique to transfer data between a browser and a server asynchronously.

In Chapter 5, Using GWT, we use Google Web Toolkit to develop an application with WildFly. According to both, the 2012 report and the 2014 report, GWT is one of the top four web frameworks.

In Chapter 6, Developing a JAX-WS 2.2 Web Service, we discuss developing an application based on the JAX-WS 2.2 standard in the Eclipse IDE using the Maven build tool. We deploy and run the application on WildFly 8.1.0.

In Chapter 7, Developing a JAX-RS 1.1 Web Service, we discuss developing a web service based on the JAX-RS 1.1 standard in the Eclipse IDE using Maven as the build tool. We deploy and run the application on WildFly 8.1.0.

In Chapter 8, Using Spring MVC 4.1, we discuss using Spring MVC with WildFly 8.1.0. According to the 2012 report, Spring MVC (at 30 percent) is the most commonly used web framework. In the 2014 report also, Spring MVC (at 40 percent) is the most commonly used web framework.

In Chapter 9, Using JAX-RS 2.0 in Java EE 7 with RESTEasy, we introduce the support for JAX-RS 2.0: the Java API for RESTful Web Services added to Java EE 7. We discuss the new Client API introduced in JAX-RS 2.0. We also discuss the asynchronous processing feature of JAX-RS 2.0.

In Chapter 10, Processing JSON with Java EE 7, we introduce another new feature in Java EE 7, that is, the support for JSR 353: Java API for JSON Processing.

What you need for this book

We have used WildFly 8.1.0 in the book. Download WildFly 8.1.0 Final from http://wildfly.org/downloads/. In some of the chapters, we have used MySQL 5.6 Database-Community Edition, which can be downloaded from http://dev.mysql.com/downloads/mysql/. You also need to download and install the Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/. Eclipse Luna 4.4.1 is used, but a later version can also be used. Also, install JBoss Tools (version 4.2.0 used) as a plugin to Eclipse. Apache Maven (version 3.05 or later) is also required to be installed and can be downloaded from http://maven.apache.org/download.cgi. We have used Windows OS, but if you have Linux installed, the book can still be used (though the source code and samples have not been tested with Linux). Slight modifications may be required with the Linux install; for example, the directory paths on Linux would be different than the Windows directory paths. You also need to install Java for Java-based chapters; Java SE 7 is used in the book.

Who this book is for

The target audience of the book is Java EE application developers. You might already be using JBoss or WildFly, but don't use the Eclipse IDE or Maven for development. The book introduces you to how the Eclipse IDE and Maven facilitate the development of Java EE applications with WildFly 8.1.0. This book is suitable for professional Java EE developers as well as beginners. The book is also suitable for an intermediate/advanced-level course in Java EE development with WildFly 8.1.0. The target audience is expected to have prior, albeit beginner-intermediate level, knowledge about the Java language and the Java EE technologies used in the book. The book also requires some familiarity with the Eclipse IDE.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Configuring the jboss-ejb3-ejb subproject."

A block of code is set as follows:

<module xmlns="urn:jboss:module:1.1" name="mysql" slot="main">
  <resources>  
    <resource-root path="mysql-connector-java-5.1.33-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
  </dependencies>
</module>

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Select Window | Preferences in Eclipse. In Preferences, select Server | Runtime Environment."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

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 send an e-mail to , and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, 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

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the 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 improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. 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 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 if you are having a problem with any aspect of the book, and we will do our best to address it.