jakarta-ee - 在 WAR 模块中打包企业 Bean

标签 jakarta-ee jar ejb war packaging

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 可以作为 Java 编程语言类文件打包在 WAR 模块中,或者打包在 WAR 模块中捆绑的 JAR 文件中

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

最佳答案

规范试图说明 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 等)。

关于jakarta-ee - 在 WAR 模块中打包企业 Bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19724150/

相关文章:

java - 异常 [EclipseLink-3002](Eclipse 持久性服务 - 2.6.2.qualifier): org. eclipse.persistence.exceptions.ConversionException

java - JAAS : on Callback ( Interesting based on HTTP headers )

java - 无法使用 VNC 访问服务器上的 jarfile

exception - 为什么我无法捕获 EJB 异常?

java - 什么是 EJB 中的本地/远程和无接口(interface) View ?

java - 反序列化无状态 EJB 时是否应用 @Resource 注释?

jakarta-ee - 事件溯源 : handle event schema changing

java - JAR 版本控制

java - 无法从 jar 文件加载 java 类

java - 使用 Arquillian 测试有状态 session Bean (arq-jbossas-remote)