[英]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.