users@glassfish.java.net

Re: Glassfish EJB 3 lookup from a client on another machine

From: Dies Koper <diesk_at_fast.au.fujitsu.com>
Date: Mon, 8 Feb 2010 10:32:37 +1100

Hi,

I have few comments that are hopefully helpful for you.

> In Glassfish the deployed Module Name is SCADA-ejb.jar, and the
> Component name is PlcServiceBean. I have tried the following in the
> local machine:
>
> InitialContext ic = new InitialContext(); ModelService mdl =
> (ModelService) ic.lookup("java:comp/env/SCADA-ejb/PlcServiceBean");
>
> and many other variations, no way. The error I get is :
>
> javax.naming.NamingException: Lookup failed for
> 'java:comp/env/PlcServiceBean' in SerialContext
> targetHost=localhost,targetPort=33835 [Root exception is
> javax.naming.NameNotFoundException: No object bound to name
> java:comp/env/PlcServiceBean]

This error message can mean many things. For instance, it can mean the
name you are trying to look up is incorrect, but it can also mean your
EJB did not start correctly. When you hot-deploy an application, or
deploy an application and then start GF, GF starts the applications one
by one. Make sure (check server.log) that your application started
successfully.
I'm not familiar with the new naming schemes with global jndi names in
EJB3.1 (and I'm no sure what GF version you are using or what EJB
version you are writing your application to), so I'm not sure about the
'SCADA-ejb' part.

> I have created a standalone POJO Client similar to the previous one
> (importing all the necessary libraries, JavaEE, Glassfish) and
> tried to connect using the following:
>
> Properties props = new Properties();
> props.setProperty("java.naming.factory.initial",
> "com.sun.enterprise.naming.SerialInitContextFactory");
> props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
> props.setProperty("org.omg.CORBA.ORBInitialPort","33878");

This is your HTTP port. You need to specify your IIOP port.

> InitialContext ic = new InitialContext(props); ModelService mdl =
> (ModelService) ic.lookup("java:comp/env/PlcServiceBean");

When using a stand-alone client (as opposed to the appclient script),
you cannot use the "java:comp/env" namespace.
The name you'll need to look up is probably "PlcServiceBean", depending
on how it's registered.

> I have looked into the ports configuration of my Glassfish under
> Netbeans and I have the following ports: HTTP ports: 33846 ,33879
> ,33878 IIOP ports: 33836 ,33835 ,33837
>
> I have tried all of them without success. I have installed another

You need the 'normal' IIOP port. Not the HTTP ports, and not the IIOP
ports related to (mutual) authentication/SSL.

HTH,
Dies