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
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:
- JMS messaging for asynchronous integration
- Web Services engine (JAX-WS and/or JAX-RS)
- Management capabilities like JMX and a scripted administration interface
- Advanced security, e.g. out-of-the-box integration with 3rd party directories
- EAR file instead of "only" WAR file support
- 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
Take a look at TOMEE
It has all the features that you need to build a complete Java EE app.
I'd certainly look to TomEE since the idea behind is to keep Tomcat bringing all the JavaEE 6 integration missing by default. That's a kind of very good compromise
Strictly speaking; With no Java EE features your app hardly need an appserver at all ;-)
Like others have pointed out JBoss has a (more or less) full Java EE stack while Tomcat is a webcontainer only. JBoss can be configured to only serve as a webcontainer as well, it'd then just be a thin wrapper around the included tomcat webcontainer. That way you could have an almost as lightweight JBoss, which would actually just be a thin "wrapper" around Tomcat. That would be almost as lightweigth.
If you won't need any of the extras JBoss has to offer, go for the one you're most comfortable with. Which is easiest to configure and maintain for you?
I have also read that for some servers one for example needs only annotate persistence contexts, but in some servers, the injection should be done manually.
精彩评论