简体   繁体   English

如何在同一WebSphere Application Server上安装的应用程序之间共享EJB本地接口?

[英]How to share EJB local interface across applications installed on the same WebSphere Application Server?

I'm having a problem with WebSphere Application Server 7. I have 2 applications installed on WAS A & B. B wants to use a local EJB interface of A's. 我在WebSphere Application Server 7上遇到问题。我在WAS A&B上安装了2个应用程序。B想使用A的本地EJB接口。

The module that contains the local EJB interface is part of A's EAR. 包含本地EJB接口的模块是A的EAR的一部分。

What I tried doing was including a reference to the module in my deployment of B. The problem I found was that, while looking up the interface: 我尝试做的是在我的B部署中包括对该模块的引用。我发现的问题是,在查找接口时:

InitialContext ic = new InitialContext();
//succeeds
Object obj = ic.lookup("ejblocal:sample.MyEJBLocal");
//fails with ClassCastException
MyEJBLocal localBean = (MyEJBLocal) obj;

The program crashes because the Interface has random letters prefixed to the name of the class, eg 程序崩溃,因为接口的类名前带有随机字母,例如

Cannot cast type SL07SMyEJBLocal to MyEJBLocal these types are incompatible.

I tried playing around with WAS & I was able to get the cast to succeed by changing the class loader settings for the server from multiple to single. 我尝试与WAS一起玩,并且通过将服务器的类加载器设置从多个更改为单个,能够成功实现转换。

Q - I don't really like the idea of having one class loader for all the applications on my server - is there another way to get the EJB local interface to be shared across application A & B? 问-我真的不喜欢在服务器上为所有应用程序使用一个类加载器的想法-是否有另一种方法来使EJB本地接口在应用程序A和B之间共享?

See the "Local client views" section of the EJB modules module of the InfoCenter (I've linked to the 8.5 InfoCenter, but the advice applies to all versions). 请参阅InfoCenter的EJB模块模块的“本地客户端视图”部分(我已链接到8.5 InfoCenter,但建议适用于所有版本)。 Basically, in order to share a local interface, you must ensure that both applications have a view of the same class. 基本上,为了共享本地接口,必须确保两个应用程序都具有相同的类的视图。 The most common approach is to use a server-associated shared library. 最常见的方法是使用与服务器相关的共享库。 Note carefully the other caveats of sharing a local EJB across applications. 请仔细注意在应用程序之间共享本地EJB的其他警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在应用程序服务器(weblogic / websphere)上部署多个应用程序 - Deploying multiple applications on an application server(weblogic/websphere) 如何在同一JVM中运行的多个应用程序(Web或ejb)之间共享实例? - How to share an instance between multiple applications (web or ejb) running in the same JVM? EJB 3.1 绑定在 Websphere Application Server 上不起作用 - EJB 3.1 Binding does not work on Websphere Application Server 我怎样才能 select EJB 的本地接口? - How can I select the local interface for an EJB? 跨应用程序查找的EJB失败 - EJB across applications lookup fails 如何知道websphere上已安装应用程序的URL - How to know the url of installed application on websphere 我的EJB应用程序没有部署在WebSphere上吗? - My EJB application is not deploying on WebSphere? 同一Websphere服务器上的2个应用程序如何才能看到彼此的静态内容? - How can 2 applications on the same websphere server see each others static content? 从WebSphere Administration Console 7.0或WebSphere Application Server的utils调用EJB无状态会话Bean方法 - Invoke EJB Stateless Session Bean method from WebSphere Administration console 7.0 or with WebSphere Application Server's utils 获取在我的Websphere服务器中安装的EJB无状态Bean内的主机和端口 - Get Host and port inside an EJB Stateless bean installed in my Websphere server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM