java - 创建供应商中立的 EJB3 客户端

标签 java jakarta-ee jboss7.x ejb-3.0 websphere-7

是否可以创建一个访问 EJB3 bean 的客户端,并且该客户端不依赖于供应商 JAR 或配置?我们目前需要支持以下场景:我们的服务部署在 WebSphere 或 JBoss 服务器上,客户端作为应用程序部署在 WAS 或 JBoss 上,或者作为独立应用程序运行。

我过去可以使用 EJB2.x bean 来做到这一点,我只需要使用 RMIC 创建 stub 。

但是对于 EJB3,如果我要连接到 WebSphere,我必须包含瘦客户端 JAR,而且我必须使用 WAS 工具预先生成 stub 。对于 JBoss,我必须使用 jboss-client.jar。

最佳答案

不,这是不可能的。这已在 EJB 3.2 规范的第 10 节中明确说明:

This chapter describes the interoperability support for accessing an enterprise bean through the EJB 2.1 remote client view from clients distributed over a network, and the distributed interoperability requirements for invocations on enterprise beans from remote clients that are Java Platform, Enterprise Edition (Java EE) components. Distributed Interoperability is not defined for the EJB 3.x remote client view.

另请注意第 10.5.5 节:

System value classes are serializable value classes implementing the javax.ejb.Handle, javax.ejb.HomeHandle, javax.ejb.EJBMetaData, java.util.Enumeration,java.util.Collection, and java.util.Iterator interfaces. These value classes are provided by the EJB container vendor. They must be provided in the form of a JAR file by the container hosting the referenced bean. For interoperability scenarios, if a referencing component would use such system value classes at runtime, the Deployer must ensure that these system value classes provided by the container hosting the referenced bean are available to the referencing component. This may be done, for example, by including these system value classes in the classpath of the referencing container, or by deploying the system value classes with the referencing component’s application by providing them to the deployment tool.

对于 WebSphere Application Server,EJB 瘦客户端包含这些系统值类以及使用 CosNaming 的 IBM JNDI 实现。理论上,如果您不需要系统值类并且您的客户端 JVM 有自己的 ORB 并实现了 CosNaming,则不需要此瘦客户端。

关于java - 创建供应商中立的 EJB3 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21901470/

相关文章:

java - Amazon AWA - 未发现类 Def 异常

java - 使用嵌入式 id 的 Hibernate 条件查询提取

Java Jackson反序列化同名但不同类类型的对象

java - 避免多项目环境中模糊依赖关系的众所周知的策略

java - HttpServlet中如何进行大数据处理?

java - 新的缺失/不满足的依赖项 : service jboss. module.spec.service

java - SLF4J + logback + JBoss 7?

java - Java中有类似sprintf的方法吗?

java - 服务器在 .ear 中找不到类

jakarta-ee - 如何在JBoss中获取当前的 `node`名称和 `cluster`名称?