460

I am starting to look into Enterprise Java and the book I am following mentions that it will use JBoss. Netbeans ships with Glassfish. I have used Tomcat in the past.

What are the differences between these three programs?

randers
  • 5,031
  • 5
  • 37
  • 64
samoz
  • 56,849
  • 55
  • 141
  • 195
  • 6
    1. http://stackoverflow.com/questions/173504/why-use-glassfish-instead-of-apache-whats-it-strengths-and-weaknesses 2. http://stackoverflow.com/questions/327793/how-would-you-compare-apache-tomcat-glassfish-as-production-servers – pramodc84 Sep 29 '10 at 12:44
  • 73
    these questions are the 'curse' of opensource. There is sometimes too many choices that do nearly the exact same thing. For newbies, it can lead to paralysis by analysis. Eclipse is the dominant IDE yet almost all books worth buying are using netbeans to develop and teach. It uses Glassfish when I've seen most businesses use Jboss in real life. There are learning curves to using each container, and it can be very frustrating for newbies. – user798719 Apr 10 '13 at 03:24
  • 1
    Now JBoss known as [WildFly] (https://en.wikipedia.org/wiki/WildFly) and JBoss was the company developed WildFly. – Chaminda Bandara May 05 '17 at 10:58
  • Similar Question: [*Java EE Web Profile vs Java EE Full Platform*](https://stackoverflow.com/q/24239978/642706) – Basil Bourque Mar 31 '18 at 20:09

8 Answers8

521

Tomcat is just a servlet container, i.e. it implements only the servlets and JSP specification. Glassfish and JBoss are full Java EE servers (including stuff like EJB, JMS, ...), with Glassfish being the reference implementation of the latest Java EE 6 stack, but JBoss in 2010 was not fully supporting it yet.

vdegenne
  • 12,272
  • 14
  • 80
  • 106
Petar Minchev
  • 46,889
  • 11
  • 103
  • 119
  • 78
    Note to readers, [JBoss is now Java EE 6 Full Profile certified](http://planet.jboss.org/post/jboss_as_7_1_0_final_thunder_released_java_ee_6_full_profile_certified) like GlassFish. As well Tomcat is now [Java EE 6 Web Profile certified via TomEE](https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces17) and supports EJB, CDI, JSF, JPA, and more. – David Blevins Jul 24 '12 at 17:35
  • 11
    @DavidBlevins so what are now the differences? – aldo.roman.nurena Aug 23 '13 at 23:07
  • 23
    @aldo.roman.nurena Very few differences. GlassFish and JBoss both support the Java EE Full Profile, so they have support for legacy technologies like JAX-RPC and CORBA. We didn't include these in the Java EE version of Tomcat, but all current technology is there like JAX-RS, JAX-WS, JMS, CDI, JPA, JSF, EJB, JTA, etc. – David Blevins Aug 26 '13 at 21:01
  • @DavidBlevins If we want to choose between JBoss and Glassfish, which is better for production environment? Are there any reference information available to understand this? – Sudhakar Chavali Oct 10 '14 at 14:17
  • @DavidBlevins Probably worth adding your info as a new answer if Peter doesn't want to update his. ? – ruffin Jul 02 '15 at 14:32
  • 1
    Editing on stackoverflow is the right way to fix answers which drift from reality too far. – Warren P Jan 28 '16 at 13:11
  • Is there no real difference when using maven then ? – Ced Jun 20 '16 at 03:14
366

Tomcat is merely an HTTP server and Java servlet container. JBoss and GlassFish are full-blown Java EE application servers, including an EJB container and all the other features of that stack. On the other hand, Tomcat has a lighter memory footprint (~60-70 MB), while those Java EE servers weigh in at hundreds of megs. Tomcat is very popular for simple web applications, or applications using frameworks such as Spring that do not require a full Java EE server. Administration of a Tomcat server is arguably easier, as there are fewer moving parts.

However, for applications that do require a full Java EE stack (or at least more pieces that could easily be bolted-on to Tomcat)... JBoss and GlassFish are two of the most popular open source offerings (the third one is Apache Geronimo, upon which the free version of IBM WebSphere is built). JBoss has a larger and deeper user community, and a more mature codebase. However, JBoss lags significantly behind GlassFish in implementing the current Java EE specs. Also, for those who prefer a GUI-based admin system... GlassFish's admin console is extremely slick, whereas most administration in JBoss is done with a command-line and text editor. GlassFish comes straight from Sun/Oracle, with all the advantages that can offer. JBoss is NOT under the control of Sun/Oracle, with all the advantages THAT can offer.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Steve Perkins
  • 11,520
  • 19
  • 63
  • 95
  • 3
    I have not validated, but [some claim](https://blogs.oracle.com/arungupta/entry/why_java_ee_6_is) that for a regular project, an EE 6 container might use 25% *less* memory than Spring + its dependencies. – Arjan Aug 23 '12 at 19:52
  • 2
    +1, excellent answer, though I subscribe to @Arjan's comment: really the memory used by these servers themselves is not that important as compared to how much memory a deployed application will need (and THAT depends strongly on the technologies used. Spring is somewhat of a memory hog) – Shivan Dragon Oct 02 '12 at 11:10
  • 10
    Heh... discussion of "servlet containers" vs. "JEE servers" always seem to turn into discussions of "Spring" vs. "EJB/JSF". I have used JEE for years, and am always happy to do so when a client pays me. However, my thoughts are: [1] most benchmarks on both sides come from biased sources, I've never noticed a big resource difference between the two stacks myself, [2] Spring is MUCH more portable than JEE "standards", with which it always seems painful to switch servers, and last but not least... – Steve Perkins Oct 03 '12 at 01:00
  • 7
    ... [3] the user communities for Spring and Hibernate absolutely dwarf those of pure JEE specs. If you run into trouble with Spring and post a question on StackOverflow, it will be read by hundreds of people and you'll have a solid answer in minutes. Ask a question about JEE stuff, and it will be read by a dozen people... and half the time, the only response you get is, "It worked for me!". The JEE standards always seem like they're a day late and a dollar short, and I feel very lonely when I run into trouble with them in a real app. – Steve Perkins Oct 03 '12 at 01:07
  • 1
    Ummmm... As of last year, Tomcat was only 13 MB, GlassFish 53MB, and JBoss 127 MB. I wouldn't consider those JavaEE servers (GlassFish and JBoss) hundreds of megs. If you are talking about WebLogic or WebSphere then we are talking about a GB. Info found at http://zeroturnaround.com/rebellabs/the-great-java-application-server-debate-with-tomcat-jboss-glassfish-jetty-and-liberty-profile/ – j will Jun 06 '14 at 17:12
  • 1
    Memory footprint while running... not the download size of their installers. – Steve Perkins Jun 06 '14 at 22:25
  • FWIW, this answer seems to have been stolen (yes, copy and pasted without any references) on [Quora by some guy](https://www.quora.com/What-are-the-differences-between-JBoss-GlassFish-and-Apache-Tomcat-servers). I have no account on quora, so I can't comment over there. – kebs Feb 14 '16 at 18:00
  • 2
    @kebs: Thanks, but pretty much ALL of StackOverflow is plagiarized on a hundred different crappy screen-scraping websites. Humans are awful, but it's not like I get paid royalties on any of my StackOverflow answers anyway. Just imaginary upvote points. :) – Steve Perkins Feb 14 '16 at 23:57
  • Given the strong dominance of Tomcat over "full J2EE server", we can realise that this environment was not so limitating after all, or that the majority of enterprises need only "simple applications" :-) – Orden Apr 14 '19 at 07:45
85

You should use GlassFish for Java EE enterprise applications. Some things to consider:

A web Server means: Handling HTTP requests (usually from browsers).

A Servlet Container (e.g. Tomcat) means: It can handle servlets & JSP.

An Application Server (e.g. GlassFish) means: *It can manage Java EE applications (usually both servlet/JSP and EJBs).


Tomcat - is run by Apache community - Open source and has two flavors:

  1. Tomcat - Web profile - lightweight which is only servlet container and does not support Java EE features like EJB, JMS etc.
  2. Tomcat EE - This is a certified Java EE container, this supports all Java EE technologies.

No commercial support available (only community support)

JBoss - Run by RedHat This is a full-stack support for JavaEE and it is a certified Java EE container. This includes Tomcat as web container internally. This also has two flavors:

  1. Community version called Application Server (AS) - this will have only community support.
  2. Enterprise Application Server (EAP) - For this, you can have a subscription-based license (It's based on the number of Cores you have on your servers.)

Glassfish - Run by Oracle This is also a full stack certified Java EE Container. This has its own web container (not Tomcat). This comes from Oracle itself, so all new specs will be tested and implemented with Glassfish first. So, always it would support the latest spec. I am not aware of its support models.

Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Jaimin Patel
  • 4,559
  • 3
  • 32
  • 35
  • 2
    Am I right to say, that nowadays (1st quarter of 2018) Glassfish doesn't really play a big role in reality? Isn't the de facto standard JBoss? – Socrates Mar 08 '18 at 14:54
14

jboss and glassfish include a servlet container(like tomcat), however the two application servers (jboss and glassfish) also provide a bean container (and a few other things aswell I imagine)

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
12

It seems a bit discouraging to use Tomcat when you read these answers. However what most fail to mention is that you can get to identical or almost identical use cases with tomcat but that requires you to add the libraries needed (through Maven or whatever include system you use).

I have been running tomcat with JPA, EJBs with very small configuration efforts.

user2130951
  • 2,601
  • 4
  • 31
  • 58
  • 3
    @MarcoOttina In my experience, yes. It's a highly configurable web server. I would guess that a lot of people building modern web apps are using it alongside Spring / Spring Boot. In all my years with Java I'm still confused by the ecosystem (particularly all the JEE stuff) as I've never had any requirement for it. Hence ending up here today :) – jocull Aug 15 '19 at 18:55
  • This answer reminds me of Apache Tomee – Sorter Sep 10 '22 at 14:51
9

JBoss and Glassfish are basically full Java EE Application Server whereas Tomcat is only a Servlet container. The main difference between JBoss, Glassfish but also WebSphere, WebLogic and so on respect to Tomcat but also Jetty, was in the functionality that an full app server offer. When you had a full stack Java EE app server you can benefit of all the implementation of the vendor of your choice, and you can benefit of EJB, JTA, CDI(JAVA EE 6+), JPA, JSF, JSP/Servlet of course and so on. With Tomcat on the other hands you can benefit only of JSP/Servlet. However to day with advanced Framework such as Spring and Guice, many of the main advantage of using an a full stack application server can be mitigate, and with the assumption of a one of this framework manly with Spring Ecosystem, you can benefit of many sub project that in the my work experience let me to left the use of a full stack app server in favour of lightweight app server like tomcat.

Valerio Vaudi
  • 4,199
  • 2
  • 24
  • 23
5

Both JBoss and Tomcat are Java servlet application servers, but JBoss is a whole lot more. The substantial difference between the two is that JBoss provides a full Java Enterprise Edition (Java EE) stack, including Enterprise JavaBeans and many other technologies that are useful for developers working on enterprise Java applications.

Tomcat is much more limited. One way to think of it is that JBoss is a Java EE stack that includes a servlet container and web server, whereas Tomcat, for the most part, is a servlet container and web server.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Spartan
  • 1,167
  • 4
  • 20
  • 40
3

Apache tomcat is just an only serverlet container it does not support for Enterprise Java application(JEE). JBoss and Glassfish are supporting for JEE application but Glassfish much heavy than JBOSS server : Reference Slide

ERK
  • 344
  • 6
  • 27
BATMAN_
  • 307
  • 3
  • 11