This post originated from an RSS feed registered with Java Buzz
by Anthony Eden.
Original Post: To EJB or not?
Feed Title: All Things
Feed URL: http://allthings.mp/
Feed Description: Blogging about Java, Python, technology and generally anything which is of interest to me.
I am about to embark on a new project which will be sold as a packaged software product meant to be deployed on customer sites. Before I begin this project though I am trying to decide on whether the application should use EJBs or whether I should stick to a web-based application using an O/R library for data persistence.
I am sure that this question comes up quite often. Back in 2002 Mike Cannon-Brookes wrote an article on this question (which is unfortunately no longer available) to which severalreadersresponded and not suprisingly most of them agreed with Mike's original points. Entity beans is a technology which was conceptually good but poorly implemented in the EJB 1.x specification.
However, that was then and this is now. EJB 2.0 introduced numerous concepts which make entity beans much more useful, specifically local interfaces and a query language. At the same time O/R tools have continued to improve as well with Hibernate the current champion of open source O/R libraries. Currently the choice is even more difficult.
Application servers are common-place in most enterprise environments nowadays and in cases where an application server is not already installed there are open sourcealternatives. However if the same application can be built without an application server then should one be used at all? Granted most application servers provide means for clustering, pooling, and so on, however most of these features can also be accomplished with just a web server albeit with a bit more work. If you want to expose an API to customers it is debatable as to whether it should be a Java API (for example through RMI) or whether a RESTsystem is better. Do you really need the power of distributed transactions when you can use database level transactions and a web-based API?
So it is clear that there are pros and cons to each approach as there always is, so that still leaves the original question: how do you choose whether to use EJBs or just do everything in the web tier?