I have an existing project that I am in need of configuring different. This needs to happen without major code changes. I am actually hoping I could somehow do this only wit
The link @Peter gave you almost solves your problem. (link)
One trick which needs to be done to solve @Xavier's problem is to provide common.jar to both ears in the same version (loaded by the same class loader). If you do it, the class cast exception will not be thrown and you will be able to use the ejb with local interface.
To do it you need to put common.jar into glassfish/domains/domain1/lib folder (substitute domain1 with you domain name). This way this jar will be loaded by a Glassfish's shared class loader.
I made a quick test with Eclipse and Glassfish 3 with following structure:
package com.example;
JarShared
- @Local class Server
EarServer
- EjbServer
- @Stateless class ServerBean implements Server
EarClient
- EjbClient
- @Stateless @LocalBean class ClientBean
Lookup from ClientBean:
InitialContext ic = new InitialContext();
Server server = (Server) ic.
lookup("java:global/EarServer/EjbServer/ServerBean!com.example.Server");
I did not get ClassCastException and I could call sample method from ServerBean.
Important notes:
If you have questions, post a comment.