views:

218

answers:

1

Hi, I have created and EJB with a remote interface:

@Stateless
public class TestSessionBean implements TestSessionRemote 
{

    public void businessMethod() 
    {
            System.out.println ("***businessMethod");
    }
}

I to access it from another component (e.g a servlet) running on the server via:

ic = new InitialContext();
ic.lookup("myEJB");

I am using netBeans 6.5.1 and glassfish v2.

How can I do that?

Thanks, Ido

+1  A: 

actually ejb3 use a default naming convention, wich i've not found a way to get around.

The name for your bean would be something like: TestSessionBean#package.TestSessionBean

To acess your remote service you can do something like this

InitialContext ctx = new InitialContext();
ctx.lookup(interfaceClass.getSimpleName()+"#"+interfaceClass.getName());

where interfaceClass is the class of your remote interface.

do note you havent defined a remote interface(or local for that matter) for that webserver. you mightnot be able to acess theejb from another context.

As for changing the name that is actually i dont think is possible through anotations. not sure though

Nuno Furtado