I'm trying to access an EJB3 from a JEE client-application, but keep getting nothing but lookup failures. The client application is running within the JEE Application Client Container.
My JEE Application 'CoreServer' is exposing a number of beans with remote interfaces. I have no problem accessing them from a Web Application deployed on the same Glassfish v3.0.1.
Now I'm trying to access it from a client-application:
public class Main {
public static void main(String[] args) {
CampaignControllerRemote bean = null;
try {
InitialContext ctx = new InitialContext();
bean = (CampaignControllerRemote) ctx.lookup("java:global/CoreServer/CampaignController");
} catch (Exception e) {
System.out.println(e.getMessage());
}
if (bean != null) {
Campaign campaign = bean.get(361);
if (campaign != null) {
System.out.println("Got "+ campaign);
}
}
}
}
When I run deploy it to Glassfish and run it from the appclient, I get this error:
Lookup failed for 'java:global/CoreServer/CampaignController' in SerialContext targetHost=localhost,targetPort=3700,orb'sInitialHost=localhost,orb'sInitialPort=3700
However, that's exactly the same JNDI-name I use when I lookup the bean from the WebApplication (via SessionContext, not InitialContext - does that matter?). Also, when I deploy 'CoreServer', Glassfish reports:
Portable JNDI names for EJB CampaignController : [java:global/CoreServer/CampaignController!mvs.api.CampaignControllerRemote, java:global/CoreServer/CampaignController]
Glassfish-specific (Non-portable) JNDI names for EJB CampaignController : [mvs.api.CampaignControllerRemote, mvs.api.CampaignControllerRemote#mvs.api.CampaignControllerRemote]
I tried all four names, none worked. Is the appclient unable to access beans with (only) Remote interfaces?