EJB3 JNDI Lookup Failure in JEE application client

Posted by Hank on Stack Overflow See other posts from Stack Overflow or by Hank
Published on 2010-04-29T13:03:06Z Indexed on 2010/04/29 13:07 UTC
Read the original article Hit count: 649

Filed under:
|
|

I'm trying to access an EJB3 from a JEE client-application, but keep getting nothing but lookup failures.

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?

© Stack Overflow or respective owner

Related posts about ejb3

Related posts about glassfishv3