Can Jetty be used as a Java EE lightweight application server?

穿精又带淫゛_ 提交于 2019-11-29 21:06:48

问题


In the scope of deploying small Java EE web applications at various client sites, I am searching for an easy application server solution.

I think I remember hearing that it was possible to use Jetty as a JavaEE 6 lightweight application server but I can't seem to find more evidence on this right now on the web.

Knowing that my development environment is JSF2 + RichFaces, CDI (Weld) and JPA 2 => NO EJBs at this point), is Jetty a possible solution for me?

If yes, could you point me to some docmentation or specific keywords helping me? If no, what other lightweight Java EE 6 application server should I use?


回答1:


Jetty is a servlet container, just like Tomcat. At the moment it's utterly unsuited as a Java EE 6 application server since the core requirement for a servlet container in that stack is being a Servlet 3.0 container.

Jetty 7, the latest stable version, is still at Servlet 2.5. At the moment nobody knows when Jetty 8, which will support Servlet 3.0 will be released, but experimental releases can already be downloaded. See http://www.eclipse.org/projects/project-plan.php?projectid=rt.jetty

Even when Jetty 8 will eventually be available, you'll of course still need to add JSF2 (Mojarra), CDI (Weld) and JPA2 (Hibernate).

Currently lightweight alternatives are Glassfish V3 (especially the Web Profile version). This weighs in at a 47MB download and gives you the full web profile. Glassfish starts up in approximately one second on modern systems and something like 2 or 3 on older ones. Memory overhead is minimal.

Yet another alternative is Caucho Resin. It's an inch away from being Java EE 6 Web Profile certified (see http://caucho.com/resin-4.0/changes/resin-4.0.14.xtp), and for all practical purposes is already fully useable as a Java EE 6 application server. Although I haven't personally used Resin, being lightweight seems to be their top priorities. (do note that 'lightweight' is a vague and much disputed term)

Finally, you could give JBoss AS 6 a spin. Few people would call JBoss AS 'lightweight' (startup time on fast hardware is at least 12 seconds, and its download size is 181MB), but its free and open source and depending on your definition of lightweight those numbers may be 'good enough'.




回答2:


I was very happy with a solution very similar to yours but using Spring 3 instead of CDI. It's almost the same. Everything was bundled inside WAR and for development mvn jetty:run was enough. No local app server needed.

However I'm sure you can embed Weld CDI implementation inside WAR. Still I'd prefer either "real" CDI JEE 6 stack or Spring.



来源:https://stackoverflow.com/questions/4903823/can-jetty-be-used-as-a-java-ee-lightweight-application-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!