How can I call a Local Session Bean inside an EAR from another EAR, both
deployed in the same Glassfish v3 domain?
This is the structure:
Glassfish v3 Domain1
EAR1
EAR1-EJB.jar
class TestSessionBean <-- @Stateless
common.jar
interface TestSessionLocal <-- @Local
EAR2
EAR2-EJB.jar
class TestSessionBeanClient <-- @Singleton, @LocalBean
common.jar
interface TestSessionLocal <-- @Local
TestSessionBean implements TestSessionLocal, boths EARs has common.jar.
I need to use TestSessionBean from TestSessionBeanClient. I would like to take
advantage of local session bean because of performance.
I know I can't use a simple @EJB call in the TestSessionBeanClient, so I tried
to lookup like this:
InitialContext ic = new InitialContext();
TestSessionLocal tsl = ic.lookup("java:global/EAR1/EAR1-EJB/TestSessionBean!org.test.TestSessionLocal");
That will throw a ClassCastException because the returned object will not be
TestSessionLocal but a proxy class like:
TestSessionLocal_1389930137
that to be able to call its methos I must do reflection to find its methods.
Please help.
Thank you in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…