People often ask me "What's the best platform for J2EE development?" There's no clear answer for this question. First, the vendors each provide contradictory facts to prove that their product is the best. Second, each has its zealots who will tell you all of the good things about one server and bad things about the others. Third, there are dozens of products available out there.
To that question, I always answer: There is not one clear winner. It all depends ... Then I suggest the following method for selecting a tool:
To help you choose the right application server, here are a few links. Some products are outdated, though:
One of the top priorities in the matrix should be price. Today's economy mandates careful investments, and free or open source software makes perfect sense. Many of these tools offer near-commercial-class stability (especially in their 2.x versions and above) with good-enough performance--and you can't beat the price! To help those people for whom price is an important factor, I've reviewed a few free or open source J2EE application servers that support EJB 2.0.
With so many products, it's easy to get lost. Foremost, I decided to ignore products that don't support EJB 2.0. That eliminates two-thirds of the candidates. Then I decided to separate my reviews into three categories:
You will note that I completely left out very popular products, including Tomcat and Enhydra. These don't have EJB containers, though. They're JSP/servlet servers.
There are a few open source J2EE servers that support EJB 2.0. These servers are, in no particular order:
JBoss is one of the most famous open source servers. It works with most of the J2EE technologies, including EJB 2.0 with CMP, JMS, JTA, Servlet/JSP, JNDI, JMX, SOAP, etc. That's a whole alphabet. JBoss uses the LGPL license.
There are two flavors of JBoss 3.0 available. One has its own HTTP server (JBossWeb), and the other one comes with Tomcat bundled. I looked at JBoss 3.0/JBossWeb, and had no problem installing, running, or configuring it. The configuration tool that comes with it is not very good, so I had to configure it manually with text and XML files. The documentation is poor, but it's enough to get you started.
This sounds too good to be true. Is there a dark side to JBoss? Not really. But there are a few things you should know:
In short, JBoss is the mother of open source J2EE application servers. For more information, see the JBoss homepage.
JOnAS is another important player in the open source J2EE server market. Like JBoss, it was originally an EJB container that was "upgraded" over time with many other J2EE technologies. It is also available under the LGPL license. In fact, the story of JOnAS sounds a great deal like that of JBoss. JOnAS supports EJB 2.0, JMS, JCA, JMX, etc. It doesn't provide Web containment, but can be used with Tomcat. This product is also bundled with Enhydra to provide EJB and JMS support.
JOnAS is managed by a group called ObjectWeb. (No, not "WebObjects.") ObjectWeb also hosts many other open source projects. The bulk of the group's members work at Bull, so obviously Bull must help out. Unlike the JBoss Group, Bull's main products are not related to open source.
JOnAS is somewhat less popular than JBoss. This is partly due to the high visibility of JBoss. (Better marketing?) I was able to get and install JOnAS easily. The examples worked fine. The configuration is done through editing text and XML files.
In short, JOnAS seems to be a good product. It would be better if it were bundled with Tomcat, and if it had a graphical configuration tool.
For more information, see the official JOnAS web site.
OpenEJB used to be a promising open source EJB container. Officially, it was "shelved" last year by Intalio, the company that was managing it. OpenEJB is still in beta state, version 0.9.1. It supports the EJB 1.1 specification, plus a few EJB 2.0 features.
Why am I talking about a product that was shelved and doesn't fully support EJB 2.0? Because the project is still alive and well. New versions come out once in a while. The mailing list receives new messages regularly. The product is still available for download. If someone wants to contribute and continue the development, the door is open.
Here's proof: in October 2002, David Blevins, co-founder of the project, wrote in a mailing-list message:
0.8 through 1.0 will all be EJB 1.1 compliant. OpenEJB 2.0 will be EJB 2.1 compliant. We already have work in progress on 2.1 compliance.
Another proof: OpenEJB is bundled with WebObjects 5.x to provide standard J2EE services.
OpenEJB has two storefronts:
OpenEJB is a member of a family of open source products, all managed by ExoLab Group, including OpenJMS (a JMS server), OpenORB (a CORBA server), Tyrex (a transaction server), and Castor (object-to-relational mapping). These can all be plugged into a Tomcat Web application.
For more information, see the OpenEJB site at SourceForge and an ONJava article on OpenEJB integration with Tomcat.
Many other application servers exist, and while they're not open source, some are free. By free I mean the license allows you to download and use the product with strict conditions. Many companies offer "free" products, which are usually limited one way or another. For example, demonstration versions expire or are incomplete. Other products limit the number of simultaneous users or lack advanced features. These companies bet that you will use the product and like it, and that you'll buy the "unlimited" versions. Despite these limitations, some of these products can very well be used for development purposes, and even for tiny projects.
Some people are afraid that if they use these commercial products, they'll be locked in. Again, J2EE applications are theoretically portable. If, later, you need a different application server, you can always migrate your application. Stick with the standard APIs in your code, and don't be afraid to use the commercial products.
Be aware that I have tried to avoid incomplete or expiring "demo" versions. This eliminates, among others, IBM's WebSphere and BEA's WebLogic application servers.
Although the SDK's reference implementation is free, and the source code is available, it is not open source, either. The license used doesn't allow modifying or reselling by the general public. It is provided for reference only. It is built on top of Tomcat, and contains a Web-based administration console.
I tried out the beta version; it was pretty buggy. Just remember that the
port used is 8000, not 8080, as suggested in the documentation
shipped with the beta version. The administrator username was
guest and the password was
The HP Application Server is an full-blown J2EE server that is part of the HP Sunset Program. What does that mean? No you don't get a free trip to Japan, the land of the setting sun, when you buy this product. It means the product has been shelved. It is still available for download, but there will be no more development, nor is there any support.
This is still an interesting product because it is commercial-quality, full-featured, and costs nothing. Find it at the HP middleware page.
This free J2EE application server comes straight from the people who manage J2EE. Can you ask for more? This version is complete, except for a handful of advanced features (management tools, load balancing, clustering, etc). Its homepage is here.
Another industrial-strength application server is EAServer. The Developer Edition is free, and, as opposed to the Sun ONE application server, it contains all features. Sybase chose to limit the number of users, instead: each server can only have five connections. Again, this can still work well for small projects. Find it here.
EJB technology is criticized for being a big burden for developers. Aren't components supposed to make their lives easier? Obviously, EJBs have a lot to offer, but are they worth the tremendous effort of manually coding them, writing big deployment descriptors, and making sure the entity beans map properly to a often-changing database? The answer is this: with good tools, EJB components make much more sense.
When these tools are free, they make perfect sense! The only question left is now "are the tools catching up"?
The most important tool is probably your IDE. It should contain the wizards, editors, and bells and whistles that provide RAD for fast EJB creation. Free IDEs like NetBeans and Eclipse lack EJB-specific features. A couple of plug-ins exist for Eclipse, but they are early versions. Sun ONE Studio Developer Edition (formerly Forte for Java) doesn't have any EJB support; the costly Enterprise Edition does.
Besides the IDE, there are many tools that help in developing EJBs. There are so many tools that I cannot list them all. For a better list, see these links:
I tried to avoid the demonstration versions. I didn't have the time to try them all, so don't blame me if some don't work as advertised.
Ant is a build utility that contains a very long list of commands. Many
compare it to the
make command, but made especially for Java
development. Some of the available commands are specific to EJBs. These
commands are vendor-specific (different ones for each application server). They
allow certain jobs to be accomplished, like compilation, packaging, deployment,
and operating the application server. See the Ant EJB
JUnit is a simple test utility. It allows easy unit testing of Java components. JUnit itself isn't made specifically for testing EJBs, although it is feasible. On the other hand, there are a few JUnit extensions (plug-ins) that make this even easier.
Probably the most famous of these extensions is Cactus.
Lomboz is an Eclipse plug-in that allows managing application servers (JBoss, WebLogic Server, Tomcat), and contains wizards to simplify J2EE development. Some of these wizards will help develop EJB 2.0 beans. This tool is integrated with XDoclet. Lomboz is at its version 0.97.x at the time I wrote this, and it worked pretty well for me. Way to go! See the Lomboz home page.
Imagine writing the bean's implementation file (annotated with many JavaDoc comments), and having a tool that generates interfaces and deployment descriptors. EJBGen is such a tool. This tool is implemented as a JavaDoc doclet. It will only generate the WebLogic-Server-specific deployment descriptor. Other application servers are not supported. EJBGen ships with WebLogic Server.
XDoclet is a tool that runs as Ant tasks to generate code automatically. Like EJBGen, XDoclet is implemented as a JavaDoc doclet. Many tags are available, each covering a different technology (EJB, JSP, JMX, etc.) or application server (WebLogic, WebSphere, JBoss, etc.). Using XDoclet, one can develop EJBs with little coding. It has a SourceForge project page.
Ejen is another solution for code generation. It is implemented as an Ant task with many options. The input format is XML. This tool has very little documentation at this time (version 1.1 beta), but I predict it will become a good alternative to the preceding code-generation solutions.
MiddleGen is a free graphical tool to generate J2EE code; by this, I mean entity beans (CMP EJB 2.0), JDO, or JSP components. Many different EJB containers are supported, including JBoss, HP AS, WebSphere, and WebLogic. How does it work? The tool connects to a database and extracts the metadata. It lets you then choose some options, and generates the entity bean code automatically! This is great! Its homepage is here.
One of the most tiresome jobs when developing EJBs is writing those darn XML deployment descriptors. These are cryptic, error-prone, and can become troublesomely large. A good XML editor is very important. There are lots to choose from. Here are a few of them:
There are a few things to remember from this article:
edlin? Do you not use a microwave oven instead of a camp fire? These gadgets are no luxury. Without them, our work would take orders of magnitude more time. The next time someone tells you how hard EJBs are to develop, tell them Writing EJBs without tools is like trying to cut down a tree with an axe. I suggest you use a chainsaw instead.
Emmanuel Proulx is an expert in J2EE and Enterprise JavaBeans, and is a certified WebLogic Server 7.0 engineer. He works in the fields of telecommunications and web development.
Return to ONJava.com.
Copyright © 2009 O'Reilly Media, Inc.