Which technologies does Tomcat support? - java

I read a lot about GlassFish application server that it supports the whole Java EE 6 specification. But which does Tomcat support?
I know that Tomcat is a JSP/Servlet container, but I see articles in web about "JSF and Tomcat", "Hibernate and Tomcat" and many more.
Can tomcat play with these technologies: EJB, JSF, JPA, Hibernate, Spring, etc..?

Tomcat as being a barebones servletcontainer provides indeed only JSP, Servlet, EL and WS APIs out the box. You can however just provide JSF, JSTL, CDI, JPA, Hibernate, Spring, etc yourself along with the web application in flavor of JAR file(s) in the /WEB-INF/lib folder and some configuration files where necessary.
EJB is only a story apart since you can't just add "some JARs" to get that to work, but in fact yes, you can put an EJB container on top of Tomcat too if you modify the server core. That's also basically what TomEE has done. You might as well consider it if your intent is to go Java EE.
See also:
What exactly is Java EE?

I read a lot about GlassFish application server that it supports the whole Java EE 6 specification. But which does Tomcat support?
Tomcat (which is not the RI of the Servlet spec anymore since Java EE 5) doesn't support any of the Java EE 6 APIs out of the box. In its latest version, Tomcat 6 ships with:
Servlet 2.5
JSP 2.1/EL 2.1
While the "web" part of GlassFish implements:
Java Servlet 3.0
JavaServer Faces 2.0
JavaServer Pages 2.2/Expression Language 2.2
Standard Tag Library for JavaServer Pages (JSTL) 1.2
Can tomcat play with these technologies: EJB, JSF, JPA, Hibernate, Spring, etc..?
You can use some of them by packaging them inside your application (this article has a nice summary):
EJB 3.1: no, there is no standalone EJB 3.1 container at the time of writing this (and if you consider using EJB, use a real Java EE server, Tomcat with a standalone EJB container is not an equivalent, especially from a Transaction Manager point of view).
JSF 2.0 and EL 2.2: yes, possible with some pain
CDI 1.0: yes, possible
Bean validation 1.0: yes possible with JSF 2.0 and JPA
JPA 2.0: yes, possible but you'll have to obtain the EntityManager yourself and to manage transaction yourself (or to use a third party container like Spring).
But let me insist: whatever you'll add to Tomcat, you won't get an equivalent of a Java EE 6 container, even if we just compare with a Web Profile implementation (like GlassFish v3 Web Profile): no EJB 3.1 Lite, no JTA 1.1, no descriptor-less applications, etc.
If you have the choice, my suggestion would to use GlassFish v3 Web Profile and to embrace Java EE 6.

Tomcat is not an EJB container, therefore you should use full blown JavaEE 6 server for that (such as Glassfish, Websphere, Weblogic, etc.).
Tomcat can use Spring/Hibernate as this only requires relevant jars and configs/context definitions. Same applies for JSF.
JPA is an abstract spec, and Hibernate (along others) is an implementation of this spec, therefore the answer is "yes, it can be implemented on Tomcat".

I found the table on the tomcat page helpful.
Page: http://tomcat.apache.org/whichversion.html

Tomcat supports depending on it's version:
JSTL 1.0 : Servlet 2.3 : JSP 1,2 (tomcat 4)
JSTL 1.1 : Servlet 2.4 : JSP 2.0 (tomcat 5)
JSTL 1.2 : Servlet 2.5 : JSP 2.1 (tomcat 6)
That tomcat offers no EJB support by default has already be answered.
EasyBeans covers this issue.
To include JSF 1.2 in tomcat6 there is a tutorial
EDIT:
Unfortunately there is no single dependency(/compatibility) matrix out there.
JPA is an API, which is implemented by i.g. Hibernate. It should not be hard to find out which versions match. And yes they can be used with Tomcat (besides) Spring.

Related

Which the versions of Tomcat and JBoss servers support CDI integration?

1) I want to know which versions of the Tomcat and JBoss servers support the CDI because I need to do a migration of applications that run on Tomcat 5
2) Where the integrations is better, in Tomcat or JBoss?
P.S: the application in question isn't distributed, has Struts, JSP, Servlet, DWR and JDBC.
Tomcat doesn't support CDI out of the box. You will need to configure it manually. If you are looking for server that provides it and is lightweight, you may check also WebSphere Liberty, which is modularized and allows you easily select what you need from Java EE stack, without fighting with 3rd party libraries.
1) CDI is supported only from Tomcat 6, however according to JBoss documentation the current supported versions for Weld (CDI reference implementation) are just 7 and 8.
2) Integration would be easier with JBoss EAP (support from EAP 5) or Wildfly, however if you don't need any Java EE technologies I would go with more lightweight server like Tomcat or Jetty. Only downside is that you have to do some tweaks in your application in order to use CDI under Tomcat or Jetty. Nice article about configuring CDI in Tomcat is this one

How to change JSP version in Tomcat?

I am upgrading my old Java webapp using JSP spec 2.0 to tomcat 7 that uses JSP specs 2.2 and the EL specs have changed much in recent versions of Tomcat 7. I have a lot of JSPs that uses old EL that are not compatible with newer versions of EL in JSP 2.2.
My question (Futile alert!), can I somehow change Tomcat 7 to use JSP 2.0 spec. You'd say why don't I use older Tomcat; I can't because I need to use Servlet 3.0 specs.
No you can't. If you somehow did, you wouldn't be able to use Servlet 3.0 because your JSP(s) are compiled into Servlets. Tomcat releases are tied to JSP and Servlet versions.
Per the Apache Tomcat 7 documentation,
Apache Tomcat version 7.0 implements the Servlet 3.0 and JavaServer Pages 2.2 specifications from the Java Community Process, and includes many additional features that make it a useful platform for developing and deploying web applications and web services.

How to run a JSF 2.0 application on JavaEE5?

For one reason or another, we need to run our JSF2 application on a JavaEE5 server (weblogic10).
Before trying to compile my application with Java5 instead of Java6, does anyone know if this will actually be possible?
JSF 2.0 is compatible with Servlet 2.5 (Java EE 5) containers. See also the Mojarra 2.0 release notes:
Webtier Specification Requirements
This release of JSF requires:
Java Servlet 2.5
JavaServerTM Pages 2.1
JavaServerTM Pages Standard Tag Library 1.2
Only JSF 2.1 requires Servlet 3.0 (Java EE 6) containers. See also the Mojarra 2.1 release notes.

What is the difference between Tomcat, JBoss and Glassfish?

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?
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.
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.
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:
Tomcat - Web profile - lightweight which is only servlet container and does not support Java EE features like EJB, JMS etc.
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:
Community version called Application Server (AS) - this will have only community support.
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.
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)
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.
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.
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.
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

Which Java Web Service Framework do you prefer?

I am gonna implement web service in Java but before implementation I will decide which framework I should use. Simplicity and running on JBoss 4.2.3 Platform are the requirements.
What is your suggestions?
Instead of using an additional technology stack component, why not use the #WebService annotation introduced in EJB3. JBoss 4.2.3 supports EJB3
Two examples
Using EJB3 Web Services guarantees that you web services will run on any Java EE compliant server without any modifications to the server.
Since JBoss provides JavaEE features, you can simply take a look at JAX-WS, annotate your EJBs, and let JBoss handle everything from there.
Otherwise you can look at Apache CXF and for JBoss + CXF see here
Axis2 on Tomcat 6
JAX-WS on Tomcat 6
Quick, Fast and Easy

Categories