Skip to main content


Showing posts from November, 2010

End of Java EE 6 show

Since last 2 days I have had lot of issues integrating JPA2 with my SLSB. Some of these are attributed to my new learning curve in Java EE 6. However with my quick exploration in last few days I can safely say that there are still serious holes in Java EE 6 world. It is slim trim and good for rapid development (unless you are on some unstable open source server) but lacks full power to drive a highly customizable and external configuration driven flexible application. These are some of my observations:Open source servers – Geronimo 3 and JBOSS 6 not yet ready. JBOSS 6 is still better. Guys for better adoption of open source we need documentation. Open source product and closed documentation will not promote this good products.Directly injecting persistence unit / entity manager results in severe cross cutting concerns. I take back my earlier word, although speed of development is important, good design goes a long way in maintenance. After writing some code in my session bean with JPA…

Adding and injecting the EJB3 session bean

In the last post the managed bean was creating the data. As a good practice the get method should never ideally do load from database or do complex time consuming operations. Its time to move the data retrieval code to a session bean( subsequently use JPA) method. In Java EE 6 it is no longer required to put the ejbs in jar files with tons of deployment descriptors. The ear file is no longer mandatory in Java EE 6. You can put your EJBs in the same war file as the web components. Ah! life is so easy and simple.
The stateless session beans(SLSB) are POJOs and can be marked as SLSB with the @Stateless annotation. Things are even easier with EJB 3.1. You no longer require the business interface. Just a concrete class will do. Although program to interface is a great principle, but for simplicity, speed of development and ease of maintenance I will stick to the new ways. The purists may frown but I cannot think when I changed an implementation midway or in later stages of a project for wh…

JSF 2.0 – First Managed Bean

The window shop, landing page is not complete. I have not shown the new product arrivals for this month in the center of the screen. In order to do that we need a managed bean which will retrieve data from the database. Later on we will integrate EJB 3.x stateless session beans to fetch the data for us. For now our managed bean will cook up the data to set the ball rolling. In this process we also discover the first domain object – Product. Going forward this will be turned into a JPA entity for CRUD operations.
Here is how the domain object looks like:
/** * */ package com.windowshop.domain.entities; import java.util.Date; import org.apache.commons.lang.builder.ToStringBuilder; /** * @author Dhrubo * */ public class Product { private int productId; private String productName; private Date createdDate; private String thumnailLocation; private String model; private double price; private String currency; public Product() {} public Product(int productId, String productName, Date cr…

Servlet 3.0 – Add frameworks as Plugins

With Servlet 3.0, it is now possible to include external or 3rd party frameworks as plug-ins to the web application. This is made possible by the ServletContainerInitializer interface. The documentation says that the implementation of this interface - “allows a library/runtime to be notified of a web application's startup phase and perform any required programmatic registration of servlets, filters, and listeners in response to it”. The servlet container finds the ServletContainerInitializer using the JAR services API during application startup. The framework implementing the ServletContainerInitializer needs to add a file named javax.servlet.ServletContainerInitializer in the META-INF/services directory of the JAR file. This file points to the implementation class of the ServletContainerInitializer.The JSF 2 Majorra implementation has used this feature. If we check the JSF-IMPL-2.x jar this file is located in META-INF/services folder and points to the class -  com.sun.faces.confi…

First Java EE 6 application

to create a Maven 2 Java EE 6 application. This will be primarily the UI part build with JSF. Primefaces is the library of choice to build the “windowshop” application. I will try to build a landing page similar to oscommerce. The figure 1 below shows a screenshot of the landing page mock up. Figure 1 – Landing page prototypeNow let us create a Maven 2 web project using the - “maven-archetype-webapp”. The listing below shows the pom.xmlListing 1 – pom.xml<project xmlns="" xmlns:xsi=""
    <name>shopweb Maven Webapp</name>

Rolling out Java EE 6 development environment

Step 0 – Download and install JDK 6Download JDK 6 from the link - Install it under c:\java.Step 1 – Download and install JBOSS 6JBOSS6M5 can be downloaded from the following link - Once downloaded unzip the file to c:\jboss6.Step 2 – Download and install EclipseEclipse Helios 3.6.1 can be downloaded from the following link - Once downloaded unzip the file to c:/eclipseStep 3 – Install Maven 2 plug-in and extrasI will prefer to use Maven 2 as my build tool. This is very useful if we also have some continuous integration system set up in future. The Maven 2 eclipse plug-in update sites are located at - Launch Eclipse and install the plug-in core and extras. In case of the…

Exploring Java EE 6

I have been using, learning and writing about Spring framework for last 5+ years now. It has done loads of good work to simplify life back in J2EE days. But off late I am seeing and participating in discussions where I see a transition back to the platform again. The reason being the Java EE 6 has adopted good ideas from frameworks like Spring, Hibernate etc and have come out with a lean and thin platform. This has not gone unnoticed in developer world. Also in last couple of years Spring’s evolution has a framework has stalled to an extent. The core framework and extensions viz Spring MVC, Security etc being stable the guys at Spring Source have focused more on servers, OSGi, cloud and adding more products to Spring Source portfolio via acquisition route. The company itself was acquired by VMWare. So lots of things happening but nothing new or exciting enough in the core area to keep the developers attracted. This is really one bad thing that runs deep inside the Java developers’ vei…