Tomcat 无法处理的 Java EE 场景
Tomcat仅实现了Java企业版架构的Web容器。相比之下,GlassFish 实现了完整的 Java EE 堆栈。这个已经在 stackoverflow 上讨论了很多。
然而,对于像我这样的 Java EE 初学者来说,很难想象 Tomcat 不能做什么。您能举一些简短的例子吗?
Tomcat only implements the web container of the Java Enterprise Edition architecture. In contrast, e.g. GlassFish implements a full Java EE stack. This has been discussed a lot on stackoverflow.
However, for a Java EE beginner like me it is hard to imagine what cannot be done with Tomcat. Could you please give some short examples?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 Apache tomcat 文档:
这意味着一些差异是...
Tomcat 可以在 J2EE 容器内部用作 Web 容器。
Tomcat 在资源和文件系统占用方面要轻得多。
如果您需要 J2EE 功能,我的建议是硬着头皮使用 Glassfish,尽管其复杂性和资源需求(与 tomcat 相比,Glassfish 与 Weblogic 和 JBoss 等其他工具相比相当容易使用)。如果没有,请坚持使用 tomcat,它会让您的事情变得简单而快速。无论哪种方式,稍后切换项目打包并更换容器并不困难。
From the Apache tomcat documentation:
Some of the differences this implies is...
Tomcat can be used inside of an J2EE conatiner to use as the web conatiner.
Tomcat is much lighter-weight regarding resources and file system foot prints.
If you need J2EE functionality, my suggestion would be to bite the bullet and use Glassfish despite the complexity and resource requirements (compared to tomcat, Glassfish is quite easy to use compared to others like Weblogic, and JBoss). If not, stick with tomcat, it will keep things simple and fast for you. Either way, it isn't hard to switch your project packaging later and swap out containers.
Java EE 包含大量技术/功能。其中一些可作为 Tomcat 下载的一部分提供,其他可以添加到基于 Tomcat 的环境中,而某些则无法添加到 Tomcat 环境中。
将 EJB jar 部署到 Tomcat 上:否。
调用 EJB 容器中运行的 EJB 的远程方法:是。
将 RAR 部署到 Tomcat:否。
将 EAR 部署到 Tomcat:否。
将应用程序客户端 jar 部署到 Tomcat:否。
拼凑出一种托管 Java Web Startable 应用程序的方法,该应用程序调用在 EJB 容器中运行的 EJB 的远程方法:是
使用 JSF 作为应用程序的框架:是的,但是您需要在应用程序中打包实现或将其安装到服务器上。
创建一个程序,利用 JSR-88 管理将 war 文件部署到 Tomcat 上:不...并不是说这是一个巨大的损失。
使用 JSR-77 MEJB 来管理您的 Tomcat 服务器:不...另一个不是巨大的损失。
创建提供 SOAP Web 服务的 Web 应用程序:是的...但是您需要单独下载工具和库,并将它们与您的工作流程、应用程序和服务器运行时集成。
创建使用 JPA 的 Web 应用程序:是的...但是您需要将工具和库作为单独下载的一部分,并自行将它们与您的工作流程、应用程序和服务器运行时集成。
创建使用 CDI 的 Web 应用程序:是的...但您需要将工具和库作为单独下载的一部分,并自行将它们与您的工作流程、应用程序和服务器运行时集成。
There are a large number of technologies/capabilities that are part of Java EE. Some of them are available as part of the Tomcat download, others can be added to a Tomcat based environment and some cannot be added to a Tomcat environment.
Deploy an EJB jar onto Tomcat: No.
Call Remote methods of an EJB running in an EJB container: Yes.
Deploy a RAR onto Tomcat: No.
Deploy an EAR onto Tomcat: No.
Deploy an Application Client jar onto Tomcat: No.
Cobble together a way to host a Java Web Startable app that calls Remote methods of an EJB running in an EJB container: Yes
Use JSF as the framework for your app: Yes, but you need to package an implementation in your app or install it onto your server.
Create a program that leverages JSR-88 to manage deployment of war files onto Tomcat: No... not that this is a huge loss.
Use JSR-77 MEJBs to manage your Tomcat server: No... another not huge loss.
Create web apps that provide SOAP web services: Yes... but you will need to get the tools and libraries as part of a separate download and integrate them with your workflow, application and server runtime yourself.
Create web apps that use JPA: Yes... but you will need to the tools and libraries as part of a separate download and integrate them with your workflow, application and server runtime yourself.
Create web apps that use CDI: Yes... but you will need to the tools and libraries as part of a separate download and integrate them with your workflow, application and server runtime yourself.
EJB - 无状态会话 Bean、有状态会话 Bean
消息驱动 Bean
EJB定时器
JPA (EJB3.0)
这是一个非常基本的列表。还有很多 Tomcat 所没有的功能。
EJBs - Stateless Session Beans, Stateful Session beans
Message driven beans
EJB Timers
JPA (EJB3.0)
This is a very basic list. there are many more features that Tomcat doesn't have.