37

I developed a small Java application using EJB3 and JSF. But I want deploy it on Tomcat server (not GlassFish and not in Netbeans IDE it has to be independent of Netbeans).

How can I deploy it on Tomcat?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
MYE
  • 983
  • 8
  • 24
  • 41
  • 1
    Also please note that Tomcat is one of the most stable and light weight server. And you may not need EJB3.1 for small to medium application though it is light weight. Because there could be team developers with expertise with java server technologies without EJB and production env is on Tomcat there is no much valid reason to move Glassfish or other Java EE6 server. I may love Glassfish3.x as an individual but it does not satisfy some of the real-time application needs. – Sree Rama Apr 09 '13 at 12:55
  • Good that you worked on Glassfish and EJB3.1. – Sree Rama Apr 09 '13 at 12:56
  • @BalusC okay, saw this so many time I started to think it was normal. – Jaffa Oct 09 '14 at 09:39

4 Answers4

56

You can, but it's not meant to happen that way. Tomcat is a servlet-container, and only application servers are required to support EJB.

Tomcat with integrated EJB support is basically TomEE. Replace Tomcat by TomEE. You can keep using the Tomcat server plugin in IDE to manage TomEE.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • 13
    Update to readers. The "OpenEJB/Tomcat" mentioned evolved into Apache TomEE which is now Java EE 6 certified like JBoss and GlassFish. – David Blevins Feb 01 '12 at 19:28
  • 5
    this is the link to add TomEE to a current Tomcat instance just deploying a war file, ja!: [Tomcat+TomEE](http://tomee.apache.org/installation-drop-in-war.html) – Sergio Aug 10 '13 at 17:51
12

use tomEE : http://openejb.apache.org/apache-tomee.html

Its a tomcat with preconfigured stuff to support ejb, cdi, etc..

Mitja Gustin
  • 1,723
  • 13
  • 17
6

You can use EJBs with Tomcat, but it's a bit painful. Check out Bozho's links for more information. The question you should be asking yourself: do you really need EJBs?

You can use Glassfish or JBoss for a free app server that has EJB support out of the box.

darioo
  • 46,442
  • 10
  • 75
  • 103
4

I think the question of asking whether you really need EJBs is almost akin to asking if you really need to use classes. As soon as you're using only a little bit of persistence (a lot of apps need that), EJB beans are a great help. Unlike their ancient ancestors, modern EJBs are very lightweight and easy to use.

That said, as the others indicated. Tomcat is only a Servlet container. It provides Servlet and JSP, nothing more. If you want modern Java conveniences like JSF, EJB and JPA (eg Hibernate), you either have to add these separately to your .war (in WEB-INF/lib) or to the lib directory of Tomcat itself.

However, if you add all that to Tomcat manually, you could just as well use Glassfish, JBoss AS, or Apache Geronimo. The last one can be seen as Tomcat where the Apache people have already added JSF, EJB, JPA, JTA, etc for you ;-)

robertgoko
  • 41
  • 1