Book Review: Java EE 6 Development with NetBeans 7

I recently posted an early preview of my thoughts on David R. Heffelfinger‘s book Java EE 6 Development with NetBeans 7. In this post, I provide a more detailed review of this book.

General Observations

In this section of my review, I make some general observations regarding the book.

Breadth of Coverage for Java EE 6 and NetBeans 7

Reviewing the Table of Contents for Java EE 6 Development with NetBeans 7 provides a quick overview of what the book covers. Its chapters cover topics such as using the NetBeans IDE, servlets and JavaServer Pages (JSP), JavaServer Faces (JSF), Java Persistence API (JPA), session beans, Contexts and Dependency Injection (CDI), Java Message Service (JMS), Java API for XML Web Services (JAX-WS), and Java API for RESTful Web Services (JAX-RS). In addition, the book features two appendices focused on debugging with NetBeans 7 and profiling with NetBeans 7.

Lots of Pictures!

Java EE 6 Development with NetBeans 7 features numerous screenshots that illustrate the points being made. The writing style is easy to read and the concepts are generally easy to follow.

Use of Keyboard Shortcuts

One of the “small” things that I really liked about this book was the consistent inclusion of NetBeans 7 keyboard short cuts and commands that can be used to perform functionality available via mouse clicks. I’ve long benefited from being aware of powerful keyboard commands that make development and code maintenance quicker. I sometimes even copy code into vim just to use a few such commands before pasting the code into my blog posts or other presentation venues.

Best Practices and Common Practices

There are several times in Java EE 6 Development with NetBeans 7 that best practices and common practices are discussed in conjunction with the particular topic being discussed. This is a natural mix of coverage of a particular portion of Java EE 6 with practices that lead to better use of that feature.

References to Additional Resources

I like the author’s liberal use of references to online resources with additional details. The book generally does a nice job of focusing on topics at an introductory level and providing some illustrative examples before referencing more detailed resources for lower level and additional details. The author has done a nice job of providing enough details in the book to get started and understand the overall concept without burdening the reader with too many details. The reader can reference the more detailed resources after gaining familiarity with the concept in general.

To Use web.xml or Not To Use It

One of the things I had heard about Java EE 6 was that web.xml is no longer required due to the heavier use of annotations. However, this book has pointed out at least three situations (web security, database access, JSF project stage) in which web.xml is either still required or may be desirable.

Specific Sections in Review

The Preface

The Preface of Java EE 6 Development with NetBeans 7 answers many of the questions that a person considering the book might ask. For example, it talks about what Java EE 6 adds to previous versions of Java EE (JSF 2.0, Servlet 3.0, and JAX-RS for example). The Preface also states the prerequisites needed to run examples from the book: Java SE 6 or newer (I’m using JDK 7) and NetBeans 7.0 Java EE Edition (I’m using the “All” edition that includes Java EE).

Perhaps the most important part of the Preface is the section that states who Java EE 6 Development with NetBeans 7 is intended for. The three types of developers forming the book’s primary audience are general Java developers wishing to learn how to use NetBeans 7 to write Java EE 6 applications, NetBeans 7 users wishing to learn how to use their IDE to developer Java EE 6 applications, and developers already familiar with Java EE 6 who wish to learn how to use NetBeans 7 in their work.

Chapter 1: Getting Started with NetBeans

The first chapter introduces the NetBeans IDE generally and describes several aspects associated with obtaining NetBeans. This section includes information on configuring an application server to be used with NetBeans 7 other than the bundled GlassFish or bundled Tomcat. It similarly covers using a relational database other than the Java DB bundled with NetBeans 7. The chapter also describes how to deploy a very simple Java EE application in NetBeans.

After the section on obtaining and configuring NetBeans and deploying a Java EE application to NetBeans, Chapter 1 moves onto coverage of NetBeans “tips for effective development.” In this section, Heffelfinger covers topics that are useful to general Java development (not limited solely to Java EE benefit). These topics include code completion, code templates, keyboard shortcuts, and visual cues. Although I have used NetBeans frequently and regularly for several years, I don’t consider myself a “power user” and I picked up several good tips for being a more effective developer with NetBeans after reading this second part of the first chapter.

Chapter 2: Developing Web Applications with Servlets and JSPs

The second chapter of Java EE 6 Development with NetBeans 7 introduces development of JavaServer Pages (JSP) with NetBeans 7. This is the first example (of several) in the book where the Java EE topic is introduced at a general and beginning level rather than focusing solely on what’s new to Java EE with Java EE 6. In other words, the treatment of JSP development with NetBeans is approached in a manner that allows even developers unfamiliar with JSPs to start using NetBeans to develop web pages based on JSP. Being fairly comfortable with JavaServer Pages, there wasn’t a lot new here for me, but it was interesting to see how much presentation assistance NetBeans provides for generating JSPs.

The second chapter also covers development of Java servlets and use of JSP fragments. It again approaches these as if the reader has little or no background with these. The chapter also covers form-based authentication in some detail and talks about the general Java EE support for form-based authentication as well as GlassFish-specific support for form-based authentication.

Chapter 3: Enhancing JSP Functionality with JSTL and Custom Tags

Chapter 3 builds on the second chapter’s introduction to JavaServer Pages. Heffelfinger first explains why custom JSP tags can lead to better JSP development and maintenance. The chapter then introduces NetBeans 7 support for core JSTL (JavaServer Pages Standard Tag Library) tags such as if, choose, and forEach.

Heffelfinger covers NetBeans 7 support for JSTL SQL tags. He demonstrates creating JSP code using NetBeans 7 JSTL support for all of the CRUD operations. I think it’s generally a bad idea for multiple reasons to access a database directly from the JSP source code. Although coverage of the JSTL SQL tags is included in the book, the author also warns that the JSTL SQL tags “tend to create applications that are hard to maintain, since they mix database access with display logic.” From his coverage of NetBeans support for using JSTL tags, Heffelfinger moves onto coverage of using NetBeans to generate the tag file for one’s own custom JSP tags.

Chapter 4: Developing Web Applications using JavaServer Faces 2.0

The fourth chapter covers JavaServer Faces. This is one of the subjects covered in this book that I have the least familiarity with, so reading it gave me a chance to see coverage of a topic from a less experienced reader’s point of view. I was pleased to learn that JSF, like other aspects of Java EE, has reduced much of its configuration requirements via annotations. It was also useful to read about when and why web.xml and faces-config.xml are required when developing JSF applications. Topics such as creating a basic input page with JSF, validating input with JSF, and providing a confirmation page with JSF are discussed in this chapter.

The chapter concludes by covering two major features new to JSF 2: using Facelets templating and JSF 2.0 custom components (composite components).

This chapter is available for download as a sample chapter from the book’s main page.

Chapter 5: Elegant Web Applications with PrimeFaces

Although I have a little experience with JSF, I have never used PrimeFaces, so this chapter was entirely new to me. The PrimeFaces main web page describes it as a “lightweight open source component suite for Java Server Faces 2.0 featuring 100+ rich set of JSF components.” The PrimeFaces Showcase (referenced in the chapter) shows off some of PrimeFaces’s impressive visual features and components.

I had not realized that PrimeFaces is bundled with NetBeans 7, but Heffelfinger demonstrates how to configure NetBeans to use PrimeFaces and provide features such as code completion related to PrimeFaces. It is clear to me after reading this chapter that PrimeFaces does indeed make use of JSF much simpler and NetBeans 7 makes the use of JSF and PrimeFaces much easier. The combination of NetBeans 7 with JSF 2 and PrimeFaces seems to put ease of development much closer to that of Flex.

Chapter 6: Interacting with Databases through the Java Persistence API

I’m a big fan of the Java Persistence API and am happy to see it get a chapter‘s focus in Java EE 6 Development with NetBeans 7. The chapter introduces JPA and creation of a JPA entity to be used in a JDF application. The default EclipseLink implementation of JPA employed by the NetBeans-bundled GlassFish is used. Although the JPA example specifically uses the NetBeans-bundled JavaDB relational database implementation, information is provided on what is necessary to connect to other data sources.

Heffelfinger provides all the information needed for someone who had never used JPA before to build his simple example in NetBeans 7 using the bundled application server, bundled database, and bundled JPA implementation. I also like that he discusses using NetBeans 7’s feature to implement Data Access Object design pattern via JPA Controller Classes. The generated classes provide basic CRUD support for the entities specified using the NetBeans 7 wizard.

The JPA chapter includes coverage of a new feature in JPA 2 and Java EE 6: bean validation. The chapter also covers how to use NetBeans 7 to generate entity beans and named queries from an existing database and then concludes with coverage of creation of a JSF application from an entity bean.

Chapter 7: Implementing the Business Tier with Session Beans

After introducing the concept of Enterprise Java Beans (EJBs) in general, this chapter delves immediately into creating session beans in any of three NetBeans 7 project types. The chapter demonstrates creation of a stateless session bean with NetBeans 7 and deploying it with a Java client library. The chapter also covers some defining features of EJBs such as transaction support and EJB timer service.

The chapter calls out many new features of Java EE 6: allowing EJBs to be deployed in WAR files, the introduction of singleton session beans (in addition to preexisting stateless and stateful session beans), removal of requirement for local interfaces, and aspect-oriented programming via interceptors. Heffelfinger concludes the chapter by describing how to “completely generate the data access layers of our application without having to write a single line of Java code.”

Chapter 8. Contexts and Dependency Injection (CDI)

CDI support is one of the most significant new features of Java EE 6, so it is not surprising that an entire chapter of Java EE 6 Development with NetBeans 7 is devoted to this subject. Although CDI can be used to “integrate various kinds of components in a loosely coupled but typesafe way” (Java EE Tutorial), it is most typically used to “make it easy for developers to use enterprise beans along with JavaServer Faces technology in web applications” (Java EE Tutorial). Chapter 8 of Java EE 6 Development with NetBeans 7 covers use of CDI and explains the “additional functionality that the CDI API provides over standard JSF.”

Chapter 9: Messaging with JMS and Message Driven Beans

Chapter 9 covers the Java Message Service and describes JMS as “a standard Java EE messaging API that allows loosely coupled, asynchronous communication between Java EE components.” I have found JMS 1.1 relatively easy to use, but its verbose boilerplate code is tedious to write (hence the popularity of Spring Framework‘s JMS Messaging).

Heffelfinger demonstrates how to use NetBeans 7 to generate much of this verbose boilerplate code normally associated with JMS. Although he talks about both queues and topics, his example focuses on creating a queue and on creating an associated connection factory. He demonstrates using NetBeans 7 to deploy newly created destination and connection factory and to create a JMS client against the deployed destination. Finally, creation of a message-driven bean (MDB) to process sent messages is demonstrated with NetBeans 7.

Chapter 10: SOAP Web Services with JAX-WS

Chapter 10 covers the general principle of a web service (whether SOAP-based or REST-based) before focusing exclusively on SOAP-based web services (REST is covered in the next chapter). I cannot think of a better candidate for the need of good tools to help with development than the SOAP-based web service. A common theme in Java EE 6 Development with NetBeans 7 is that of using NetBeans 7 to reduce the boilerplate code a developer needs to write. There are many areas of Java EE 6 where this is true, but it is no more true than in the area of SOAP-based web services and JAX-WS.

Heffelfinger opens up his discussion on NetBeans 7 support for SOAP-based web services by introducing WSDL and by discussing how NetBeans 7 allows for either top-down (contact first with Java generated from existing WSDL) or bottom-up (WSDL generated from existing Java classes) development of SOAP-based web services. He provides an example of generating a simple length conversion web service using NetBeans 7’s wizard, changing the body of the generated methods on the properly annotated Java POJO, and automatically generating WSDL and a client to test the simple web service.

The second example and third example use JAX-WS to expose a stateless session EJB as a web service. One of these examples demonstrates this by creating the EJB in conjunction with creation of a web service and the other of these examples demonstrates this by creating a web service on an existing EJB.

There are many who argue that contract-based, top-down web service design is the preferred approach. This is demonstrated in this chapter via an example that shows generation of Java classes with stub methods based on a provided existing WSDL.

Chapter 11: RESTful Web Services with JAX-RS

One of the most exciting additions to Java EE 6 is that of JAX-RS to support RESTful web services. I have blogged on REST and on JAX-RS before and really like much about both. It is nice to see a chapter of Java EE 6 Development with NetBeans 7 devoted to JAX-RS and REST in Java EE 6 with NetBeans.

Heffelfinger begins his coverage of Java EE 6/JAX-RS support in NetBeans 7 with a discussion on and demonstration of generating a REST-based web service from an existing database. The discussion includes details of what NetBeans does to make this happen, including the use of JPA facsdes and the typical use of Jersey.

As was done for coverage of NetBeans 7 with JAX-WS, this chapter demonstrates how to use NetBeans 7 to test a newly created REST-based web service and how to use NetBeans 7 to generate a client of the REST-based web service. I thought it was interesting, albeit not surprising, that the client API used for the generated client is Jersey’s Client API. This makes it easy for NetBeans 7 to create methods for handling both XML and JSON.

Appendix A: Debugging Enterprise Applications with the NetBeans Debugger

I’m not normally the type of reader to “skip to the end,” but I must admit that I read the Appendices first in this case. The reason for this is that I was curious regarding what the author had to say regarding debugging and profiling in NetBeans 7. For the most part, the coverage of both debugging and profiling in NetBeans 7 is largely applicable to any Java development, enterprise or standard.

Appendix A covers debugging with NetBeans 7 and does provide some information specific to debugging Java EE applications. The chapter describes using NetBeans 7 with the embedded GlassFish instance to essentially boil initial enterprise debugging steps down to a single step. Another piece of the NetBeans 7 debugging coverage that is specific to Java EE is the example itself. The example is intentionally broken so that debugging effort is needed and the example is based on Java EE technologies JSF, CDI, and JPA.

Fortunately for developers familiar with using NetBeans for debugging standard Java applications, the process for debugging enterprise Java applications is very similar. For example, the steps of setting breakpoints, stepping over, stepping into, and using the Local Variables window are the same as for standard applications.

Appendix B: Identifying Performance Issues with the NetBeans Profiler

The final portion of Java EE 6 Development with NetBeans 7 is an appendix focused on profiling with NetBeans 7. Appendix B is a relatively short appendix, but it does give an overview of the types of information that NetBeans 7 provides that can be used to identify performance issues. There is some discussion of how memory leaks can occur in Java, a principle worth understanding whether working on standard or enterprise Java applications.

The Drawbacks

Nothing is perfect and no book is perfect. Although there are some issues with Java EE 6 Development with NetBeans 7, they tend to be very minor and are not overly distracting. There is the occasional expected erratum and I thought a few of the sentences were a little too choppy, but the message was always relayed. Overall, the text was highly readable and was conducive to relaying the message rather than distracting from it.

It would be easy to say that the most significant drawback of the book is that it doesn’t cover every single NetBeans feature or every single nuance of Java EE. However, I’d argue that details of that level are best left to books that are exclusively focused on particular aspects. For example, I’d expect to use a book centered on JavaServer Faces to learn the gritty details of using JSF. The focus of Java EE 6 Development with NetBeans 7 is clearly on introducing development of Java EE 6 applications using NetBeans 7 as its title implies. The book is written so that developers are only expected to have basic Java SE familiarity, but can be new to both Java EE and NetBeans. I like the author’s style of introducing the most important concepts at a high level, showing them in demonstrations, and then referring to other resources for details that would have perhaps gotten in the way if covered in the introductory text.

This book is perfect for the developer who wishes to get a thorough introduction to Java EE and NetBeans 7, but it is not (and I doubt it was intended to be) a comprehensive Java EE reference. Similarly, it is also not a comprehensive NetBeans 7 reference. However, it does cover a wide swath of the most important features of both individually and as used together.

Other Characteristics

Although Java EE 6 Development with NetBeans 7 is almost 400 pages in length, it reads much more quickly than similar technical books of similar size because of the numerous screenshots. There are significant code samples included as well, which may lead to a reader spending more or less time than he or she would on text.

According to the book’s web page, Java EE 6 Development with NetBeans 7 was released in June 2011 and has an ISBN of 1849512701. It is written in English and is available in printed format or in multiple electronic formats (PDF or ePub download or via PacktLib). I reviewed the downloaded PDF version.


I enjoyed reading and reviewing Java EE 6 Development with NetBeans 7. Because I have done most of my Java EE development with a different IDE and have used NetBeans mostly for Java SE/Spring/Groovy development, it was an eye-opener to see how useful NetBeans 7 can be for Java EE development. I also learned quite a bit about areas of Java EE that I am less familiar with (CDI, JSF, PrimeFaces) and even learned some smaller but still useful tips regarding areas of Java EE I am more familiar with.

Java EE 6 Development with NetBeans 7 provides introductory coverage to Java EE 6. It does not focus solely on topics new to Java EE 6, but instead covers Java EE as a whole from an introductory level and happens to include some Java EE 6 new features in that coverage. There are some entire new chapters on entirely new Java EE 6 features such as CDI and JAX-RS support, but most of the chapters include relevant Java EE topics that were the same clear back in the days of J2EE.

Java EE 6 Development with NetBeans 7 demonstrates via discussion and numerous screenshots how to employ NetBeans 7 and its many wizards to generate significant code and configuration for a Java EE 6 project. Best and common practices related to Java EE 6 development are sprinkled throughout this introductory discussion and references to online resources with greater detail are provided.

Java EE 6 Development with NetBeans 7 is particularly beneficial for developers with little or no Java EE experience who want to use NetBeans 7 to generate Java EE 6 applications. In a single book, such developers can find solid introductory coverage of both Java EE 6 topics and how to use NetBeans 7 to most easily employ those features. Even developers new to Java EE who are not necessarily planning on using NetBeans may find this useful as they could use NetBeans 7 to generate boilerplate code and configuration files that they could use to learn what they needed to write or maintain in their own preferred IDE.

This entry was posted in Book Review, Java EE 6, NetBeans, Syndicated. Bookmark the permalink.

Comments are closed.