How to deploy EJB based application on Tomcat
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?
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.
use tomEE : http://openejb.apache.org/apache-tomee.html
Its a tomcat with preconfigured stuff to support ejb, cdi, etc..
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.
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 ;-)
精彩评论