views:

170

answers:

4

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..?

A: 

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".

mindas
+3  A: 

Tomcat ships with builtin JSP/Servlet API. You can of course add JSF/JPA/Hibernate/Spring/etc yourself in flavor of JAR file(s) in the /WEB-INF/lib of your webapplication.

EJB is only a story apart since you can't just add "some JAR's" to get that to work, but in fact yes, you can put an EJB container on top of Tomcat. That's also basically what JBoss AS has done.

BalusC
thanks for your great Answers.i find this link for using EclipseLink (JPA 2.0) with Tomcat : http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial
ManWard
You're welcome. That's indeed a good tutorial.
BalusC
A: 

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 ansered. EasyBeans covers this issue.

To include JSF 1.2 in tomcat6 there is a tutorial

EDIT: Unfortunatly 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.

stacker
+2  A: 

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.

Pascal Thivent