Thursday, July 28, 2011

EE Server versus Tomcat/Jetty

First off, I like Tomcat.  It starts fast, is a solid JSP/Servlet container and, when coupled with Spring, gives a well rounded application development framework.  However, I also like Weblogic, Glassfish and JBoss.  EE6 containers with EJB3, CDI/Weld and JSF/Facelets also gives a solid application development framework.  So what's the difference, and why or when should you use one over the other?


  1. Connection Pooling vs C3PO
  2. JTA vs Atomikos
  3. JMS vs ActiveMQ/RabbitMQ
  4. JAX-RS/WS vs Metro or CXF
  5. EE Security (5 specs) vs JSecurity or Spring Security
  6. EE Interceptors vs Spring Events


So it appears as though you can add in each of the EE stack specs into Tomcat as needed.  The real question becomes what is as needed and do you design your application around what's missing as much as what's there?

Lightweight
Tomcat/Jetty/Resin will all start using less memory than Glassfish/JBoss.  If however, you need connection to a database(s) (issues 1 and 2 above), asynchronous processing (issue 3), restful web services (issue 4), security (5) and loose coupling (6) then you'll need to add Spring to your web app on Tomcat/Jetty/Resin and then the startup times and memory footprint begins to look similar.

Vendor Independence
Tomcat with Spring gives you lots of configuration options.  Different implementations of JCA, JMS, Web Services, Security, Persistence can all be wired in to the environment.  This is a great advantage when dealing with existing application infrastructure where synergy to other applications is required.  As much as JEE vendors purport that the EE spec isolates you from vendor lockin, it's more difficult to perform than the color glossy brochure would have you believe.  The ability to deploy a war on multiple JEE servers does exist, so there is that level of independence, but it's generally much easier to use the vendor's chosen implementations of security, persistence, jms, etc.

Testing
Spring has a great test framework to allow testing from junit or testng without a container.  Since Spring is independent of container provided services, you can pretty easily spin up a Spring configuration in the JVM.  JEE testing requires a container.  With frameworks like arquillian, it's easier to spin up a embedded container for testing, but Spring has a definite advantage here.

Free
What a misnomer.  Often we think that because we can download a product and use it without paying, that it is free.  Well, I guess if we already knew everything we needed to know to use the product -- it would be free.  But, when you try to use the software you just download for the first time, there's usually some learning curve.  Documentation, community involvement, support and professional services can all come into play in order to get you up and running.  My opinion is that the Spring documentation is pretty good here.  The JEE documentation (link below) is good also, but note quite as polished as Spring's.  The issue with Spring, is that the variety of implementations for any of the basic services, means you will be dependent on additional vendor documentation, unless you simply use what Spring recommends.  So the vendor independence advantage may be a little diluted.

Why Use JEE
If you have a clean slate to start with, i.e. very few mandates to use a particular implementation of Security, WebService engine, etc.  Also, if you really don't care who provides your connection pooling, JMS, JCA, JTA, etc. then a JEE server will provide all of those basic services.   You have development and deployment hardware capable of supporting a reasonably large memory footprint.

Why Use Spring
You want customize and tailor the configuration of the basic application infrastructure.  You want to learn technology that is widely spread.  You want to learn technology that can be used in a variety application ecosystems.  You are severely limited in the development or deployment hardware.


references:
EE Doc: http://download.oracle.com/javaee/6/tutorial/doc/gfirp.html
Spring Doc: http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/

1 comment:

  1. Well, after spending about an hour trying to setup Spring Greenhouse this morning, I'm less enthralled with Spring's documentation. "Get the source" is a one liner in the getting started page, and I've not successfully cloned and built the project yet. Looked at some source code and it's pretty shabby looking -- lot's of org.springsource code in the project itself.

    ReplyDelete