giving an EJB a JNDI

狂风中的少年 提交于 2019-12-11 07:37:11

问题


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:


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



来源:https://stackoverflow.com/questions/676926/giving-an-ejb-a-jndi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!