Alex Averbuch
Alex Averbuch

Reputation: 3325

Hibernate & EJB3.1 in Tomcat - what is needed to make this possible?

I have three general JavaEE + Tomcat questions:

  1. According to this link (Using Hibernate with Tomcat) running Hibernate in Tomcat is possible (despite Tomcat not supporting JPA). Does anyone know if I'll run into problems with this configuration (Hibernate on Tomcat)?

  2. Can I do something similar to get EJB3.1 support in Tomcat? For example, by dropping the correct files into WEB-INF/lib and WEB-INF/classes could I run EJB3.1 in a standard Tomcat7 container (not TomEE)? If yes, which EJB3.1 providers are recommended?

  3. Generally, is it possible to run any JavaEE technology from within Tomcat as long as the appropriate libraries and configuration files are placed in WEB-INF/lib and WEB-INF/classes? Or, is it only possible to run the technologies for which Tomcat supports the interfaces?

Thanks in advance for all help!

Upvotes: 2

Views: 3518

Answers (3)

JB Nizet
JB Nizet

Reputation: 692121

  1. You won't run into problems, but you'll have to handle transactions and session handling yourself, unless you use Spring for example.

  2. No.

  3. No.

Tomcat is a servlet and JSP container, and not a full-stack Java EE container. A Java EE container must support EAR files, and Tomcat only deploys WAR files. Stuffing libraries into a WAR file won't make it an EAR file.

Upvotes: 0

Mike Braun
Mike Braun

Reputation: 3769

Many things that are in Java EE can be added to Tomcat. TomEE is the living proof of that. What TomEE does is mostly what you can also do.

It's really typical to add JPA (Hibernate) and a JTA transaction manager (Atomikos, JoTM, etc) to Tomcat. Next on the list is JSF (Mojarra or MyFaces) and CDI (Weld). JAX-RS (Jersey, RestEasy) can also be added.

At the end you could ask yourself if it isn't easier to just install TomEE or GlassFish though...

Upvotes: 0

sourcedelica
sourcedelica

Reputation: 24047

  1. No problems - it's very common.
  2. Yes. For example OpenEJB is the predecessor to TomEE. Per the downloads page (below).
  3. No.

Drop-in WARs.

A version of Apache OpenEJB that can be dropped into any Tomcat 7.x install effectively creating your own Apache TomEE Web Profile or Apache TomEE Plus.

Upvotes: 3

Related Questions