I'm have obtained the following certifications to date:

  • Sun Certified Developer for Java Web Services 5
  • Sun Certified Specialist for NetBeans IDE
  • Sun Certified Solaris 10 System Administrator
  • Sun Certified Developer for Java 2 platform
  • Sun Certified Enterprise Architect for the Java Platform, Enterprise Edition 5
  • Sun Certified Programmer for Java 2 platform 1.4
  • Sun Certified Enterprise Architect for J2EE 1.4 Technology
  • IBM Certified SOA Solution Designer
  • IBM Certified Solution Designer – WebSphere MQ V5.3
  • IBM Certified Deployment Professional – WebSphere Studio Application Monitor V3.2
  • IBM Certified Application Developer – Rational Application Developer for WebSphere V6
  • IBM Certified Advanced System Administrator – WebSphere Application Server 5.0
  • IBM Certified System Administrator – WebSphere Application Server 5.0
Christopher has posted 2 posts at DZone. View Full User Profile

How to Create a Java EE 6 Application with JSF 2, EJB 3.1, JPA, and NetBeans IDE 6.8

  • submit to reddit
There are many articles and tutorials out there that discuss how to use the individual technologies in Java EE 6, e.g., JSF 2, EJB 3.1, JPA, etc, to develop an application, but I haven't seen one that puts together the said technologies and showcases them in one tutorial with an end-to-end demonstration. As such, I thought I would create one here for the benefit of those who are new to JEE6 and NetBeans IDE 6.8 and those who are seriously looking at NetBeans IDE 6.8 as a tool for developing their enterprise applications.

This article aims to provide detailed steps to develop a web-based application based on technologies in the JEE6 specs, i.e., JavaServer Faces 2.0 (JSF), Enterprise Java Beans 3.1 (Session Bean and Message-Driven Bean) and Java Persistence API (JPA) with the help of NetBeans IDE 6.8 as the development & deployment tool. The example in this tutorial creates a web application called "CustomerApp" that performs only the Retrieve and Update functions of CRUD on the customer records provided by the NetBeans Sample database served by the Glassfish built-in database server, JavaDB (Derby). In addition to the above-mentioned technologies from JEE6, PrimeFaces for JSF2 will also be used as the Ajax-based Framework for the Web UI portion which is lacking in the stack. So, this tutorial also discusses how PrimeFaces can be integrated into NetBeans IDE and to enable Ajax capabilities for Web projects.

The objective of this tutorial is to demonstrate the ease of using the various JEE6 technologies and putting them together to create an enterprise-ready web-based application. Although the application is developed for demo purposes, its architecture represents the best practices in developing an enterprise application, whereby modularity, scalability, and reusability are taken into consideration.

The architecture of the application is shown in the above diagram, where it is organized into various tiers: Presentation, Business, Data Access and Data, where each has an important role to play and is segregated from one another. This architecture encourages a clean separation of responsibilities, reusability, and scalability through the use of Enterprise Java Beans. With the use of JSF and JPA, GUI development becomes a breeze and developers are no longer bogged down by the tedious and error-prone chores of converting relational data to OO, which is natural in Java and vice versa. So, all-in-all, this demo not only demonstrates the use of the various JEE6 technologies, it also demonstrates the best-of-breed application architecture that can be used in a production system.


The rest of this article consists of the following sections:


Published at DZone with permission of its author, Christopher Lam.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Prashanth Kumar replied on Sat, 2010/05/22 - 10:21am

I am sort of stuck. When try to load the webpage, i only get the table header. No table data. I have not yet started to apply the primeface. It sort of looks like the Managed bean is not getting called. One question, when we drap and drop the JSF data table from entity , the pop up dialog has the cutomer entity bean in the list how the Managed bean property is empty. I had to type in customer.customers . Is that normal or should the IDE able to load the data based on entity bean.

Prashanth Kumar replied on Wed, 2010/06/02 - 11:11am in response to: Prashanth Kumar

Sorry, I figured out my mistake as to why the JSF table was not loading data. I had a extra space after the ManagedBean name anotation. Now I am able to see the JSF table with the pagination. However as i am using JSF2.0 , i have to figure out how to navigate from listing page to details page

Thang Pham replied on Thu, 2010/06/03 - 9:08am

I could not deploy the CustomerApp-war, so I create my own version of your application and try to deploy CustomerApp-war every time I add a new component. I figure out that the problem is when I add NotificationBean (Message Driven Bean). Particularly with the annotation @MessageDriven

@MessageDriven(mappedName = "jms/NotificationQueue", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })

Any Idea why? If I remove the annotation above, it deploy just fine. The server log show the Exception: "Message Driven Bean can't be Managed Bean". How can I fix this?

Thang Pham replied on Thu, 2010/06/03 - 10:40am in response to: Thang Pham

This is a bug in glassfish v3.0.0. Download glassfish v.3.0.1 for the fix

Thang Pham replied on Thu, 2010/06/03 - 10:47am

Hi I am bit confused about the NotificationBean (Message Driven Bean). So in your SessionBean, you merge a give "customer" into the persistent state then you send that object to the NotificationQueue. Here is where I got confused. Why and who do you try to send notification to? Where does "customer" object go after it get in the queue? When will the method onMessage(Message message) got invoke? Sorry I am a bit new to JPA.

Thang Pham replied on Thu, 2010/06/03 - 11:20am in response to: Henk De Boer

Do you have a tutorial some what like this but implemented correctly i like you mention above?

Naresh Amma replied on Tue, 2010/09/21 - 6:58am

just to get in to this account nothin to say k?

Naresh Amma replied on Tue, 2010/09/21 - 7:11am in response to: Rudy Hadoux


Musa Musa L replied on Tue, 2010/09/28 - 1:34pm

Hello, I was following your netbeans JavaEE 6 tutorial @ http://wiki.netbeans.org/DevelopJavaEE6App and i got stuck at this place 
<!-- Replace outputText with commandLink here to navigate 
                    to the details page -->
                    <h:commandLink action="#{customer.showDetails(item)}"
the server is having problems with the showDetails(item) call, since EL can only call managed bean properties with getters and setters
How do i solve this? Thanks. 
I used a f:setPropertyActionListener tag to set the current customer object to the selected item. it's all good

Suraj Chhetry replied on Thu, 2010/10/21 - 12:32am

Hi Christopher, Can you tell me know can i caught exception on manage bean that is thrown by EJB bean ?

Suraj Chhetry replied on Thu, 2010/10/21 - 12:52am

I got it Iam extending my exception class from RuntimeException so it is not coming to manage bean but when i extends from Exception it is working.

Vasko Gjurovski replied on Wed, 2010/11/17 - 10:53am

I am having problem with the navigation rules. I did everything as been told above in the tutorial, however tho links to the detail pages do not do anything. I even putted a System.out.println in the showDetails method, but nothing is printed out. Any idea what might be causing this?

Gökhan Ozar replied on Thu, 2010/11/25 - 4:01pm

Hi, Thanks for the great tutorial which I really admire. I have gone through the tutorial with PrimeFaces 2.1 which is the latest stable release as of this writing, and my CustomerList.xhtml has a slightly different output on http://localhost:8080/CustomerApp-war/CustomerList.jsf with no pagination or column sorting options. I took it that it should be automatic from what I see in the output in your tutorial. So is it the version difference of PrimeFaces? BTW, the zip file of the completed app on the summary page is still corrupt or incomplete, so I can't compare. Please consider re-uploading it.

Cassio Seffrin replied on Mon, 2011/01/24 - 12:30pm

Hi Christopher,

First: congratulations you made a great job. wonderfull tutorial.

Second:  following your tuto the application work fine for me. To complete the CRUD, lack only do the add page. I think this is simple, but I'm not so familiar to JSF. You have a sample code for this application?

The persist method in the EJB it's done, lack only create a request (buttom create) and change something in CustomerDetails.jsf, but if you have a sample will be appreciated?

Best Regard,


Soumaya Touati replied on Wed, 2011/07/13 - 1:29pm in response to: Christopher Lam

HI Christopher thank you for the tutorial "How to Create a Java EE 6 Application with JSF 2, EJB 3.1, JPA, and NetBeans IDE 6.8" it was very helpful for me. please i need your help to create a new customer its very urgent please help me i need it to accomplish my work .

Sameera Samarasinghe replied on Thu, 2011/07/28 - 6:13am

Hi, When I try to create the template for XHTML I got "No library found for this namespace" error for the followings xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.prime.com.tr/ui" please help me with this. Thanks :) Sameera

Sameera Samarasinghe replied on Thu, 2011/07/28 - 7:22am

once the DOCTYPE statement removed there's no error.
Please help me

Navpreet Singh replied on Thu, 2011/08/18 - 6:35pm

Hi Christopher,

Thanks for the great tutorial. It works and I learned a lot along the way. 

But when I start following your next tutorial


At the end when I go to CustomerList.jsp in browser and click on first record it opens up CustomerDetails.jsp without redirecting me to Login.jsp.
I even copied your solution still it goes to CustomerDetails.jsp without login. Can you please help me with this?



Raul Lapitzondo replied on Fri, 2011/11/11 - 9:36am in response to: Christopher Lam

Thank's for this tutorial is a great job.

I need understand the first part, about how to create "jms/NotificationQueue" in glassfish server. Can you explain this ?.

Thank's in advance

James Jithin replied on Tue, 2012/01/31 - 2:15am

Great tutorial. Screen-shots are good to follow. Also, makes us work a little to achieve the goal. :) Good work.

Manish Chowdhary replied on Thu, 2012/03/22 - 8:10pm

Do you have an updated blog post for this? GoECart

Matt Coleman replied on Mon, 2013/04/01 - 3:55am in response to: Cagatay Civici

thanks for this information Cagatay

buffalo freelance web designer 

Isaac Mashoboko replied on Wed, 2013/10/09 - 12:47pm

Thank for the great tutorial. This tutorial is all about updating and retrieving customers. I'd like to ask how can i include customer registration code in the project. sorry for my bad english.

thank you

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.