Reputation: 46
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.
The module that contains the local EJB interface is part of A's 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:
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, e.g.
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.
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?
Upvotes: 1
Views: 2517
Reputation: 33946
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). 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.
Upvotes: 1