JBoss vs Tomcat again

Ashish picture Ashish · Jan 12, 2011 · Viewed 160.9k times · Source

This will appear to be the age old question (which it is :)) that which server is better between Tomcat and JBoss, but I have not found a good enough answer yet to solve my problem.

I know that Tomcat is only a servlet engine and JBoss offers many more functionalities out of the box, but what I fail to understand is why Tomcat is better to use in some situations than jboss. I read somewhere that JBoss has a pluggable architecture and if required, you can unplug features from JBoss to make it essentially a tomcat servlet container. If that is the case, then isn't it better to do so instead of using Tomcat, in order to leave scope for plugging things back.

Another explanation I find in favour of Tomcat is that it is lightweight, does that mean less memory requirement or does that also allows faster response. Again, I need to know that won't jboss load components as per requirement i.e. if i am using only servlets, then won't jboss skip the rest of the features and become lightweight automatically.

Essentially, my application does not have any Java EE features, but the 'lightweight' arguments in favour of Tomcat does not sound convincing enough because of the above mentioned reasons.

Please help.

Edit: We had finally decided to use tomcat back then and we have been using it for more than 6 months now with great ease of use. Infact we found some practical use where we could very easily run multiple tomcat instances on the same server machine for different developers, the same could have been very difficult with jboss.

I have found tomcat to be hassle free for our work and therefore may be the right choice when you are not using much of Java EE features. PS: Please note that we still use Spring and Hibernate with Tomcat

Answer

home picture home · Jul 30, 2011

First the facts, neither is better. As you already mentioned, Tomcat provides a servlet container that supports the Servlet specification (Tomcat 7 supports Servlet 3.0). JBoss AS, a 'complete' application server supports Java EE 6 (including Servlet 3.0) in its current version.

Tomcat is fairly lightweight and in case you need certain Java EE features beyond the Servlet API, you can easily enhance Tomcat by providing the required libraries as part of your application. For example, if you need JPA features you can include Hibernate or OpenEJB and JPA works nearly out of the box.

How to decide whether to use Tomcat or a full stack Java EE application server:

When starting your project you should have an idea what it requires. If you're in a large enterprise environment JBoss (or any other Java EE server) might be the right choice as it provides built-in support for e.g:

  1. JMS messaging for asynchronous integration
  2. Web Services engine (JAX-WS and/or JAX-RS)
  3. Management capabilities like JMX and a scripted administration interface
  4. Advanced security, e.g. out-of-the-box integration with 3rd party directories
  5. EAR file instead of "only" WAR file support
  6. all the other "great" Java EE features I can't remember :-)

In my opinion Tomcat is a very good fit if it comes to web centric, user facing applications. If backend integration comes into play, a Java EE application server should be (at least) considered. Last but not least, migrating a WAR developed for Tomcat to JBoss should be a 1 day excercise.

Second, you should also take the usage inside your environment into account. In case your organization already runs say 1,000 JBoss instances, you might always go with that regardless of your concrete requirements (consider aspects like cost for operations or upskilling). Of course, this applies vice versa.

my 2 cent