【问题标题】:Packaging Enterprise Beans in WAR Modules在 WAR 模块中打包企业 Bean
【发布时间】:2013-11-01 09:36:35
【问题描述】:

JavaEE 7 tutorial

以下提到

Enterprise beans often provide the business logic of a web application. In these cases,
packaging the enterprise bean within the web application's WAR module simplifies
deployment and application organization. Enterprise beans may be packaged within a
WAR module as Java programming language class files or within a JAR file that is
bundled within the WAR module.

过了一会儿

JAR files that contain enterprise bean classes packaged within a WAR module are not
considered EJB JAR files, even if the bundled JAR file conforms to the format of an EJB
JAR file. The enterprise beans contained within the JAR file are semantically
equivalent to enterprise beans located in the WAR module's WEB-INF/classes directory,
and the environment namespace of all the enterprise beans are scoped to the WAR module.

我无法通过这部分来理解这个例子。

这怎么可能

企业 bean 可以打包在 WAR 模块中作为 Java 编程语言类文件或打包在 WAR 模块中的 JAR 文件中

包含打包在 WAR 模块中的企业 bean 类的 JAR 文件不被视为 EJB JAR 文件,即使捆绑的 JAR 文件符合 EJB JAR 文件的格式。

【问题讨论】:

    标签: jakarta-ee jar ejb war packaging


    【解决方案1】:

    规范试图说明 EJB 注释将在 WEB-INF/classes/ 中的类或 WEB-INF/lib/ 中的 JAR 中被识别,但如果您决定将预先存在的 EJB 模块 JAR 移动到 WEB-INF/lib/ 中,它将是解释为常规 JAR,而不是独立的 EJB 模块,这意味着该 JAR 中特定于模块的部署描述符将被忽略(例如,META-INF/ejb-jar.xmlMETA-INF/validation.xmlMETA-INF/beans.xml 等)。相反,这些描述符需要合并在一起并放入包含 WAR 的 WEB-INF/(例如,WEB-INF/ejb-jar.xml 等)。

    【讨论】:

    • 解释一下,你的意思是EJB类被服务器管理为EJB类,它们的部署描述符必须位于WAR的META-INF目录中,而不是EJB部署如果将 JAR 放置在 WAR 的 lib 文件夹中,是否会考虑 JAR 的 META-INF 目录中的描述符?而注释,可以让你从部署描述符中解脱出来,它将强制服务器管理 EJB 服务,无论它们是在 WEB-INF/classes/ 目录中还是打包在 META-INF 目录下的 JAR 中?
    • 是的(假设您的意思是“必须位于 WAR 的 WEB-INF 目录中”)。
    • @BrettKail,如果您愿意提供有关如何将 EJB 打包为 JAR 的更多文档的链接,将不胜感激。
    • EJB 3.2 specification的第15章。
    猜你喜欢
    • 1970-01-01
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-28
    相关资源
    最近更新 更多