Thursday, October 26, 2006

Is BEA far ahead in Java EE 5 game?

It was interesting to read this article in Dr Dobb's Java portal (and InfoQ' s thread ) that noted that BEA is ahead of others in the Java EE 5 game. In my personal opinion (note that this blog is my personal opinion and nothing to do with my employer's), these are really biased articles and reflects the mindset of the writer "BEA is always ahead!"

As per the article EJB 3/JPA covers significant portions of Java EE 5 and hence the reality shows otherwise. Oracle and JBoss had EJB 3 previews for years (yes years, we released our first EJB 3 preview in early March 2005, See my announcement) and both JBoss and Oracle have production release of EJB 3/JPA in their application server. Look for complete EJB 3/ JPA support in Oracle Application Server 10g 10.1.3.1 whereas BEA just has tech preview of a subset of EJB 3 specification. They have support for Java Persistence API in Kodo but the article in DDJ also acknowledges Kodo is not yet integrated with the WebLogic and hence you cannot use its full power. However Oracle’s JPA implementation TopLink Essentials is totally integrated with Oracle's Java EE container (OC4J) and is also shipped with Glassfish, TmaxSoft and popular Spring 2.0!.

Beside full implementation of EJB 3 and JPA, Oracle has also support for Web services metadata, annotations support in the Servlet (2.5) and application client container in Oracle Application Server (10.1.3.1). Above all these features work in a truly integrated fashion that customers can use in production today. You cannot use JSR-181 annotations with an EJB 3 session bean in a production environment with WebLogic but can do that today with OracleAS !

Try running a complicated application such as Java Adventure Builder that uses EJB 3 /JPA / Web services metadata in the WebLogic Tech Preview. If you can’t do these things then what made the author to assume that BEA is ahead of JBoss and Oracle in the Java EE 5 game.

It truly frustrates me when seeing such biased articles because many gullible readers treat such articles as bible.

Many Oracle customers have started deploying EJB 3.0/JPA applications in production. Can you do that with BEA? If not then how can you say that they are ahead in the game!


EJB 3 In Action: What's what in EJB 3

Manning has made available 9 chapters of EJB 3 In Action as part of MEAP Release. Draft version of chapter 1 “What’s what in EJB 3" is available for free. Take a look at this at http://manning.com/panda/.

You will probably like the beginning story of an Indian boy named Sadhu and it's comparison with EJB’s incarnations. You can access the chapter at http://manning.com/panda/.

Wednesday, October 25, 2006

Java annotations support in the web container

Servlet 2.5 (a part of Java EE 5) provides support for Java metadata annotations. You can use annotations for callback methods, security, injection of resources, EJB and web service reference, EntityManager, etc.

You can also package a persistence module (EJB3 JPA entities) as a part of a WAR module.

Injection of Resources

You can use the @Resource annotation to inject resource references such as Data Source e.g. you can inject a Data Source as follows:

@Resource(name="jdbc/OracleDS")
private DataSource dataSource;


CallBack Methods

You can use @PostConstruct and @PreDestroy annotations with any arbitrary method to behave like init() and destroy() methods respectively. For example you can have a method named openConnection that opens a connection as follows:

@PostConstruct
public void openConnection() {
try {
connection = dataSource.getConnection();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}


Things to Remember


Note that annotations are supported only with managed classes such as servlet, filters, listeners, etc. You cannot use annotations with regular POJOs.

You have to make sure that you have set version=”2.5” in the web.xml for the web-app tag as follows: ...

...


If you have set that to a lower version or not set then container will not search for annotations and you will probably get a NullPointerException at run time when trying to use a field assuming it’s value to populated using injection.

OC4J 10.1.3.1 supports all Servlet 2.5 annotations that includes @EJB, @Resource, @Resources, @PostConstruct, @PreDestroy, @PersistenceUnit(s), @PersistenceContext(s), @WebServiceRef, @DeclaresRoles, @RunAs.

It also allows packaging of EJB 3/JPA entities in the web module.

Missing annotations ..!

I think one think that is missing is that there are annotations to specify a type of an object similar to @Stateless annotation in EJB 3.0.

For example, you CANNOT mark a POJO to be a servlet as follows:
@Servlet
public class MyServlet
{ …
}

I would like to see annotations such as @Servlet or @Filter in future version of Servlet specification.

More Info

You can find more about Servlet annotations in Servlet 2.5 spec or OC4J 10.1.3.1 documentation.


Friday, October 20, 2006

Oracle Application Server 10.1.3.1 Goes Production

Oracle announced production release of Oracle Application Server10g 10.1.3.1. This release of OC4J implements significant features of Java EE 5.0 that includes full implementation EJB 3.0, JPA 1.0, Common Metadata annotations 1.0, Servlet 2.5 annotations, annotations support in the Application Client Container support and web services metadata.

You can download from OC4J home page at http://www.oracle.com/technology/tech/java/oc4j/index.html

Oracle Application Server 10.1.3.1 Goes Production

Oracle announced production release of Oracle Application Server10g 10.1.3.1. This release of OC4J implements significant features of Java EE 5.0 that includes full implementation EJB 3.0, JPA 1.0, Common Metadata annotations 1.0, Servlet 2.5 annotations, annotations support in the Application Client Container support and web services metadata.

You can download from OC4J home page at http://www.oracle.com/technology/tech/java/oc4j/index.html

Friday, October 13, 2006

Early Access Edition of EJB 3 In Action

I participated in several beta and early access testing of products, reviewed books but never participated in an Early Access Program for a book. And certainly Manning Early Access Program sounds interesting.

An early release version of my book EJB 3 Action is now available at http://manning.com/panda/

It's a little better form of pre-ordering from Amazon or a publisher web site. You immediately get access to the source or final pre-production version of the book online and Manning Publications will ship you a book as soon as book is published. In the mean time you are the beta testers of the book (:

I will appreciate you participate in this program, pre-order a copy and help find any errors in the book (: